Completed
Last Updated: 02 Mar 2022 13:27 by ADMIN
ADMIN
Danail Vasilev
Created on: 11 Jun 2015 06:04
Category: HtmlChart
Type: Feature Request
1
Control the explode level of exploded Pie chart items
A possible workaround: 
	<form id="form1" runat="server">
		<telerik:RadScriptManager ID="RadScriptManager1" runat="server"></telerik:RadScriptManager>
		<script>
			var ExplodeLevel = 0.15;
		</script>
		<telerik:RadHtmlChart runat="server" ID="PieChart1" Transitions="true">
			<PlotArea>
				<Series>
					<telerik:PieSeries StartAngle="90">
						<LabelsAppearance Position="OutsideEnd" DataFormatString="{0} %" />
						<TooltipsAppearance DataFormatString="{0} %" />
						<SeriesItems>
							<telerik:PieSeriesItem BackgroundColor="Purple" Exploded="true" Name="Internet Explorer" Y="18.3" />
							<telerik:PieSeriesItem BackgroundColor="Orange" Exploded="false" Name="Firefox" Y="35.8" />
							<telerik:PieSeriesItem BackgroundColor="Green" Exploded="false" Name="Chrome" Y="38.3" />
							<telerik:PieSeriesItem BackgroundColor="Blue" Exploded="true" Name="Safari" Y="4.5" />
							<telerik:PieSeriesItem BackgroundColor="Red" Exploded="false" Name="Opera" Y="2.3" />
						</SeriesItems>
					</telerik:PieSeries>
				</Series>
			</PlotArea>
			<ChartTitle Text="Browser Usage for April 2012">
			</ChartTitle>
		</telerik:RadHtmlChart>
		<script>
			var math = Math,
				dataviz = kendo.dataviz,
				Box2D = dataviz.Box2D,
				Point2D = dataviz.Point2D,
				OUTSIDE_END = "outsideEnd",
				RIGHT = "right",
				util = kendo.util,
				valueOrDefault = util.valueOrDefault;

			kendo.dataviz.PieChart.fn.reflow = function (targetBox) {
				var chart = this,
					options = chart.options,
					box = targetBox.clone(),
					space = 5,
					minWidth = math.min(box.width(), box.height()),
					halfMinWidth = minWidth / 2,
					defaultPadding = minWidth - minWidth * 0.85,
					padding = valueOrDefault(options.padding, defaultPadding),
					newBox = Box2D(box.x1, box.y1,
					box.x1 + minWidth, box.y1 + minWidth),
					newBoxCenter = newBox.center(),
					seriesConfigs = chart.seriesConfigs || [],
					boxCenter = box.center(),
					points = chart.points,
					count = points.length,
					seriesCount = options.series.length,
					leftSideLabels = [],
					rightSideLabels = [],
					seriesConfig, seriesIndex, label,
					segment, sector, r, i, c;

				padding = padding > halfMinWidth - space ? halfMinWidth - space : padding;
				newBox.translate(boxCenter.x - newBoxCenter.x, boxCenter.y - newBoxCenter.y);
				r = halfMinWidth - padding;
				c = Point2D(
					r + newBox.x1 + padding,
					r + newBox.y1 + padding
				);

				for (i = 0; i < count; i++) {
					segment = points[i];

					sector = segment.sector;
					sector.r = r;
					sector.c = c;
					seriesIndex = segment.seriesIx;
					if (seriesConfigs.length) {
						seriesConfig = seriesConfigs[seriesIndex];
						sector.ir = seriesConfig.ir;
						sector.r = seriesConfig.r;
					}

					if (seriesIndex == seriesCount - 1 && segment.explode) {
						sector.c = sector.clone().radius(sector.r * ExplodeLevel).point(sector.middle());
					}

					segment.reflow(newBox);

					label = segment.label;
					if (label) {
						if (label.options.position === OUTSIDE_END) {
							if (seriesIndex == seriesCount - 1) {
								if (label.orientation === RIGHT) {
									rightSideLabels.push(label);
								} else {
									leftSideLabels.push(label);
								}
							}
						}
					}
				}

				if (leftSideLabels.length > 0) {
					leftSideLabels.sort(chart.labelComparator(true));
					chart.leftLabelsReflow(leftSideLabels);
				}

				if (rightSideLabels.length > 0) {
					rightSideLabels.sort(chart.labelComparator(false));
					chart.rightLabelsReflow(rightSideLabels);
				}

				chart.box = newBox;
			};
		</script>
	</form>
1 comment
ADMIN
Rumen
Posted on: 02 Mar 2022 13:27
Please use the solution provided by Danail.