Currently, the HighlightAppearance of the Series does not have a property that controls the InactiveOpacity:
As a temporary workaround, this can be set through the options in the OnKendoWidgetInitializing event:
<script>
function OnKendoWidgetInitializing(sender, args) {
var series = args.series[0]
series.highlight = series.highlight || {};
series.highlight.inactiveOpacity = 0.2
}
</script>
<telerik:RadHtmlChart ID="RadHtmlChart5" runat="server" BorderColor="Fuchsia" BorderStyle="Solid" BorderWidth="1px">
<ClientEvents OnKendoWidgetInitializing="OnKendoWidgetInitializing" />
<PlotArea>
<Series>
<telerik:PieSeries StartAngle="90">
<%-- This is how it should be configured after the feature request --%>
<%--<HighlightAppearance InactiveOpacity="0.2" />--%>
<SeriesItems>
<telerik:PieSeriesItem Name="Slice1" Y="60"></telerik:PieSeriesItem>
<telerik:PieSeriesItem Name="Slice2" Y="40"></telerik:PieSeriesItem>
</SeriesItems>
</telerik:PieSeries>
</Series>
</PlotArea>
</telerik:RadHtmlChart>
My objective is to compare product revenue over time. This I would like to achieve using data binding. I do not have information of product names or have the product names as columns. My data table structure is having three columns: Date Product Name Revenue This I should simply be able to achieve using data binding to a table with above three columns. In result I expect each of the Product Names to appear as independent series with revenues plotted on different dates. A similar graph is displayed in the Line Chart documentation for RadHtmlChart. https://docs.telerik.com/devtools/aspnet-ajax/controls/htmlchart/chart-types/line-chart
I would like to request a new feature in legend of RadHtmlChart that provide a tool-tip for long names because when I add a long text in legends the size of pie-chart is reduced. Sample code for what I expect to be working : <telerik:RadHtmlChart runat="server" ID="Chart" Height="400px" Width="400px"> <ClientEvents OnLoad="onChartLoad" /> function onChartLoad() { var chart = $find("Chart"); var widget = chart.get_kendoWidget(); widget.options.legend.tooltip = "#: dataItem.columnname #" //Feature Request in this line widget.redraw(); }
Hi! I don't know if could be a other type for the html chart control. I want a donut with only 2 series like a points in a exam for example 100/120 and the points 100 shows in the center of the donut, maybe I would like to change the 100 points with a image
For the time being the following events can be handled through the chartObject. Select event is fired when the range of the selector from the navigator pane is changed. JavaScript: <telerik:RadCodeBlock ID="RadCodeBlock1" runat="server"> <script> function pageLoad() { var chart = $find('<%=RadHtmlChart1.ClientID%>'); chart._chartObject.bind("selectEnd", OnSelectEnd); } function OnSelectEnd(e) { alert("OnSelectEnd triggered: \nFrom: " + e.from + "\n To: " + e.to); } </script> </telerik:RadCodeBlock> ASPX: <telerik:RadHtmlChart runat="server" ID="RadHtmlChart1" Layout="Stock" Width="800" Height="400" Transitions="true"> <PlotArea> <XAxis Name="mainAxis" DataLabelsField="SellDate" Type="Date"> </XAxis> <Series> <telerik:ColumnSeries DataFieldY="SellQuantity"> </telerik:ColumnSeries> </Series> </PlotArea> <Navigator Visible="true"> <XAxis Name="navAxis"></XAxis> <SelectionHint Visible="true" /> <Series> <telerik:AreaSeries DataFieldY="SellQuantity"> </telerik:AreaSeries> </Series> </Navigator> </telerik:RadHtmlChart> C#: protected void Page_Load(object sender, EventArgs e) { RadHtmlChart1.DataSource = GetData(); RadHtmlChart1.DataBind(); } protected DataTable GetData() { DataTable dt = new DataTable(); dt.Columns.Add("ID", typeof(int)); dt.Columns.Add("SellQuantity", typeof(int)); dt.Columns.Add("SellDate", typeof(DateTime)); dt.Rows.Add(1, 2, new DateTime(2011, 06, 12)); dt.Rows.Add(1, 5, new DateTime(2011, 12, 12)); dt.Rows.Add(2, 6, new DateTime(2012, 06, 17)); dt.Rows.Add(3, 4, new DateTime(2012, 09, 18)); dt.Rows.Add(4, 7, new DateTime(2013, 03, 18)); return dt; }
A good improvement in the RadHtmlChart would be to add MaxSize and MinSize properties for the series, which would allow the control the scaling of the bubble chart item. The property can be set through the chartObject: <script> function pageLoad() { var chart = $find("<%=BubbleChart.ClientID%>"); chart.get_kendoWidget().options.series[0].minSize = 1; chart.get_kendoWidget().options.series[0].maxSize = 10; chart.get_kendoWidget().redraw(); } </script> ASPX: <telerik:RadHtmlChart runat="server" ID="BubbleChart" Width="500" Height="400"> <PlotArea> <Series> <telerik:BubbleSeries> <Appearance FillStyle-BackgroundColor="#6ab2c9"> </Appearance> <SeriesItems> <telerik:BubbleSeriesItem Size="1" X="5" Y="5500" /> <telerik:BubbleSeriesItem Size="5" X="14" Y="12200" /> <telerik:BubbleSeriesItem Size="15" X="20" Y="39000" /> </SeriesItems> </telerik:BubbleSeries> </Series> </PlotArea> </telerik:RadHtmlChart> More detailed information regarding these properties can be found in the API reference of the Kendo UI Chart here: http://docs.telerik.com/kendo-ui/api/javascript/dataviz/ui/chart#configuration-series.maxSize
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>
The chart's labels also look misaligned in rtl direction, so you can change only chart's direction to ltr with CSS: <style> .RadHtmlChart { direction: ltr; } </style> <div dir="rtl"> some text <telerik:RadHtmlChart ID="RadHtmlChart1" runat="server" Width="600" Height="400"> <PlotArea> <Series> <telerik:ColumnSeries Name="Series 1"> <SeriesItems> <telerik:CategorySeriesItem Y="30" /> <telerik:CategorySeriesItem Y="10" /> <telerik:CategorySeriesItem Y="20" /> </SeriesItems> </telerik:ColumnSeries> </Series> <XAxis> <LabelsAppearance RotationAngle="33"></LabelsAppearance> <Items> <telerik:AxisItem LabelText="Item 1" /> <telerik:AxisItem LabelText="Item 2" /> <telerik:AxisItem LabelText="Item 3" /> </Items> </XAxis> </PlotArea> </telerik:RadHtmlChart> </div>
allow for the chart plot area to be fixed width not counting the axis text. the issue I have is the legend on right side of chart changes the widths of chart when the text is long.
A visual example - http://i.stack.imgur.com/zRwlo.jpg The feature will be useful for projects that need 508 compliance. A boolean properties will also be useful: "EnabledTexturedFill", "EnableColorAndTexturedFill"
I would like to suggest ability to display data series in doughnut and pie charts, see attached example from Excel. And thanks for a great Telerik experience, you make my development work very easy.
For the time being you can use a JavaScript function inside the template to cut the labels - http://docs.telerik.com/kendo-ui/dataviz/chart/how-to/shorten-chart-labels
For the time being you can manually fetch the data and pass it to the chart: <script> function pageLoad() { var dataSource = $find('<%= RadClientDataSource1.ClientID %>'); dataSource.fetch(function (args) { var data = args.get_data(), chart = $find('<%=RadHtmlChart1.ClientID%>'); //workaround chart.set_dataSource(data); chart.repaint(); }); } </script> <telerik:RadClientDataSource ID="RadClientDataSource1" runat="server"> <DataSource> <WebServiceDataSourceSettings> <Select Url="spain-electricity.json" DataType="JSON" /> </WebServiceDataSourceSettings> </DataSource> <Schema> <Model> <telerik:ClientDataSourceModelField FieldName="year" DataType="String" /> <telerik:ClientDataSourceModelField FieldName="solar" DataType="Number" /> </Model> </Schema> </telerik:RadClientDataSource> <telerik:RadHtmlChart ID="RadHtmlChart1" runat="server" ClientDataSourceID="RadClientDataSource1"> <PlotArea> <Series> <telerik:LineSeries DataFieldY="year" Name="year"> </telerik:LineSeries> </Series> <XAxis DataLabelsField="year"></XAxis> </PlotArea> </telerik:RadHtmlChart>
For the time being the function can be set through the kendoWidget: <telerik:RadHtmlChart runat="server" ID="ColumnChart1" Transitions="true"> <PlotArea> <Series> <telerik:ColumnSeries Name="Product 1"> <TooltipsAppearance BackgroundColor="Orange" DataFormatString="{0} sales" /> <SeriesItems> <telerik:CategorySeriesItem Y="15000" /> <telerik:CategorySeriesItem Y="23000" /> <telerik:CategorySeriesItem Y="10000" /> <telerik:CategorySeriesItem Y="16000" /> </SeriesItems> </telerik:ColumnSeries> </Series> <XAxis AxisCrossingValue="0" Color="Black" MajorTickType="Outside" MinorTickType="Outside" Reversed="false"> <Items> <telerik:AxisItem LabelText="1" /> <telerik:AxisItem LabelText="2" /> <telerik:AxisItem LabelText="3" /> <telerik:AxisItem LabelText="4" /> </Items> <LabelsAppearance DataFormatString="Q{0}" RotationAngle="0" /> <MajorGridLines Color="#EFEFEF" Width="1" /> <MinorGridLines Color="#F7F7F7" Width="1" /> <TitleAppearance Position="Center" RotationAngle="0" Text="Quarters" /> </XAxis> <YAxis AxisCrossingValue="0" Color="Black" MajorTickSize="1" MajorTickType="Outside" MaxValue="50000" MinorTickSize="1" MinorTickType="Outside" MinValue="0" Reversed="false" Step="10000"> <LabelsAppearance DataFormatString="{0} sales" RotationAngle="0" /> <TitleAppearance Position="Center" RotationAngle="0" Text="Sales" /> </YAxis> </PlotArea> <ChartTitle Text="Product Sales for 2011"> </ChartTitle> <Legend> <Appearance Position="Bottom" /> </Legend> </telerik:RadHtmlChart> <script> function pageLoad() { $ = $telerik.$; var kendoWidget = $find("<%=ColumnChart1.ClientID%>").get_kendoWidget(); kendoWidget.options.series[0].labels.position = function (point) { if (point.value < 20000) { console.log(1); return "insideEnd"; } else { console.log(2); return "outsideEnd"; } } kendoWidget.redraw(); } </script>
The property (http://docs.telerik.com/kendo-ui/api/javascript/dataviz/ui/chart#configuration-categoryAxis.maxDateGroups) can be set through the kendoWidget: JavaScript: <script> function OnLoad(args) { var kendoWidget = args.get_kendoWidget(); kendoWidget.options.categoryAxis.maxDateGroups = 8; kendoWidget.options.categoryAxis.baseUnit = 'fit'; kendoWidget.redraw(); } </script> ASPX: <telerik:RadHtmlChart runat="server" ID="RadHtmlChart2" Width="640px" Height="480px"> <ClientEvents OnLoad="OnLoad" /> <PlotArea> <Series> <telerik:LineSeries DataFieldY="SellQuantity"> <LabelsAppearance DataFormatString="{1} cars sold on {0:m}"> </LabelsAppearance> <TooltipsAppearance Color="White" DataFormatString="{1} cars sold on<br/>{0:D}" /> </telerik:LineSeries> </Series> <XAxis DataLabelsField="SellDate"> <TitleAppearance Text="Sell Date"> </TitleAppearance> <LabelsAppearance DataFormatString="d"> </LabelsAppearance> <MajorGridLines Color="#EFEFEF" Width="1"></MajorGridLines> <MinorGridLines Color="#F7F7F7" Width="1"></MinorGridLines> </XAxis> <YAxis> <TitleAppearance Text="Quantity"> </TitleAppearance> <MajorGridLines Color="#EFEFEF" Width="1"></MajorGridLines> <MinorGridLines Color="#F7F7F7" Width="1"></MinorGridLines> </YAxis> </PlotArea> <ChartTitle Text="Sold Cars per Date"> </ChartTitle> </telerik:RadHtmlChart> C#: protected void Page_Load(object sender, EventArgs e) { RadHtmlChart2.DataSource = GetData(); RadHtmlChart2.DataBind(); } protected DataTable GetData() { DataTable dt = new DataTable(); dt.Columns.Add("ID", typeof(int)); dt.Columns.Add("SellQuantity", typeof(int)); dt.Columns.Add("SellDate", typeof(DateTime)); dt.Rows.Add(1, 2, new DateTime(2011, 06, 12)); dt.Rows.Add(2, 5, new DateTime(2011, 12, 12)); dt.Rows.Add(3, 6, new DateTime(2012, 06, 17)); dt.Rows.Add(4, 4, new DateTime(2012, 09, 18)); dt.Rows.Add(5, 7, new DateTime(2013, 03, 18)); return dt; }
Would be nice to be able to supply an image for the series background on bar and column charts, this would enable infographic style option to charts, i.e. displaying data for countries the bar series can be repeating national flags.
For the time being you can choose either approach: 1) Set the min and max dates on the kendo widget: ASPX: <script> function pageLoad() { var chart = $find("<%=RadHtmlChart1.ClientID%>"); chart._chartObject.options.xAxis.min = new Date(2013, 04, 01); chart._chartObject.options.xAxis.max = new Date(2013, 05, 01); chart.repaint(); } </script> <telerik:RadHtmlChart runat="server" ID="RadHtmlChart1" Width="640px" Height="480px"> <PlotArea> <Series> <telerik:ScatterLineSeries DataFieldY="SellQuantity" DataFieldX="SellDate"> <LabelsAppearance DataFormatString="{1} cars sold on {0:m}"> </LabelsAppearance> <TooltipsAppearance Color="White" DataFormatString="{1} cars sold on<br/>{0:D}" /> </telerik:ScatterLineSeries> </Series> <XAxis BaseUnit="Days"> <TitleAppearance Text="Sell Date"> </TitleAppearance> <LabelsAppearance DataFormatString="d" RotationAngle="45"> </LabelsAppearance> <MajorGridLines Color="#EFEFEF" Width="1"></MajorGridLines> <MinorGridLines Color="#F7F7F7" Width="1"></MinorGridLines> </XAxis> <YAxis> <TitleAppearance Text="Quantity"> </TitleAppearance> <MajorGridLines Color="#EFEFEF" Width="1"></MajorGridLines> <MinorGridLines Color="#F7F7F7" Width="1"></MinorGridLines> </YAxis> </PlotArea> <ChartTitle Text="Sold Cars per Date"> </ChartTitle> </telerik:RadHtmlChart> C#: protected void Page_Load(object sender, EventArgs e) { RadHtmlChart1.DataSource = GetData(); RadHtmlChart1.DataBind(); } protected DataTable GetData() { DataTable dt = new DataTable(); dt.Columns.Add("ID", typeof(int)); dt.Columns.Add("SellQuantity", typeof(int)); dt.Columns.Add("SellDate", typeof(DateTime)); dt.Rows.Add(1, 2, new DateTime(2013, 05, 12)); dt.Rows.Add(2, 5, new DateTime(2013, 05, 13)); dt.Rows.Add(3, 6, new DateTime(2013, 05, 17)); dt.Rows.Add(4, 4, new DateTime(2013, 05, 18)); dt.Rows.Add(5, 7, new DateTime(2013, 05, 22)); return dt; } 2) Set the JavaScript equivalent of min and max dates in the code behind like follows: C#: protected void Page_Load(object sender, EventArgs e) { //Set min and max date for a datetime x-axis type RadHtmlChart1.PlotArea.XAxis.MinValue = ConvertToJavaScriptDateTime(new DateTime(2014, 02, 19)); RadHtmlChart1.PlotArea.XAxis.MaxValue = ConvertToJavaScriptDateTime(new DateTime(2014, 04, 05)); //Instantiate ScatterSeriesItem objects ScatterSeriesItem ssi1 = new ScatterSeriesItem(); ScatterSeriesItem ssi2 = new ScatterSeriesItem(); ScatterSeriesItem ssi3 = new ScatterSeriesItem(); ScatterSeriesItem ssi4 = new ScatterSeriesItem(); //Instantiate DateTime objects DateTime date1 = (new DateTime(2014, 03, 03, 0, 0, 0)); DateTime date2 = (new DateTime(2014, 03, 10, 0, 0, 0)); DateTime date3 = (new DateTime(2014, 03, 17, 0, 0, 0)); DateTime date4 = (new DateTime(2014, 03, 24, 0, 0, 0)); //Set the converted x values to the ScatterSeriesItem objects ssi1.X = ConvertToJavaScriptDateTime(date1); ssi2.X = ConvertToJavaScriptDateTime(date2); ssi3.X = ConvertToJavaScriptDateTime(date3); ssi4.X = ConvertToJavaScriptDateTime(date4); //Set the y values to the ScatterSeriesItem objects ssi1.Y = 3; ssi2.Y = 6; ssi3.Y = 5; ssi4.Y = 9; //Add the ScatterSeriesItem objects to the ScatterLineSeries (RadHtmlChart1.PlotArea.Series[0] as ScatterLineSeries).SeriesItems.Add(ssi1); (RadHtmlChart1.PlotArea.Series[0] as ScatterLineSeries).SeriesItems.Add(ssi2); (RadHtmlChart1.PlotArea.Series[0] as ScatterLineSeries).SeriesItems.Add(ssi3); (RadHtmlChart1.PlotArea.Series[0] as ScatterLineSeries).SeriesItems.Add(ssi4); } //A method that converts the .NET DateTime object to its JavaScript Date object representation protected decimal ConvertToJavaScriptDateTime(DateTime fromDate) { return (decimal)fromDate.Subtract(new DateTime(1970, 1, 1)).TotalMilliseconds; } ASPX: <telerik:RadHtmlChart runat="server" ID="RadHtmlChart1" Width="640px" Height="480px"> <PlotArea> <Series> <telerik:ScatterLineSeries Name="Stock A"> <LabelsAppearance> <ClientTemplate> #= kendo.format(\'{0:d/MM/yyyy}\', new Date(value.x)) #, #=kendo.format(\'{0:C0}\',value.y)# </ClientTemplate> </LabelsAppearance> <TooltipsAppearance Color="White"> <ClientTemplate> #= kendo.format(\'{0:d/MM/yyyy}\', new Date(value.x)) #, #=kendo.format(\'{0:C0}\',value.y)# </ClientTemplate> </TooltipsAppearance> </telerik:ScatterLineSeries> </Series> <YAxis> <LabelsAppearance DataFormatString="C0"></LabelsAppearance> <TitleAppearance Text="Price"></TitleAppearance> </YAxis> <XAxis Type="Date" BaseUnit="Days"> <TitleAppearance Text="Closing Date"> </TitleAppearance> <LabelsAppearance DataFormatString="d"> </LabelsAppearance> </XAxis> </PlotArea> <ChartTitle Text="Closing Stock Prices"> </ChartTitle> </telerik:RadHtmlChart>
For the time being you can use the following workaround: <script> function OnLoad(sender, args) { var kendoWidget = $find('<%=RadHtmlChart1.ClientID%>').get_kendoWidget(); kendoWidget.options.legend.reverse = true; kendoWidget.redraw(); } </script> <telerik:RadHtmlChart ID="RadHtmlChart1" runat="server" Width="600" Height="400"> <ClientEvents OnLoad="OnLoad" /> <PlotArea> <Series> <telerik:ColumnSeries Name="Series 1"> <SeriesItems> <telerik:CategorySeriesItem Y="30" /> <telerik:CategorySeriesItem Y="10" /> <telerik:CategorySeriesItem Y="20" /> </SeriesItems> </telerik:ColumnSeries> <telerik:ColumnSeries Name="Series 2"> <SeriesItems> <telerik:CategorySeriesItem Y="2" /> <telerik:CategorySeriesItem Y="5" /> <telerik:CategorySeriesItem Y="7" /> </SeriesItems> </telerik:ColumnSeries> <telerik:ColumnSeries Name="Series 3"> <SeriesItems> <telerik:CategorySeriesItem Y="9" /> <telerik:CategorySeriesItem Y="11" /> <telerik:CategorySeriesItem Y="13" /> </SeriesItems> </telerik:ColumnSeries> </Series> <XAxis> <LabelsAppearance RotationAngle="33"></LabelsAppearance> <Items> <telerik:AxisItem LabelText="Item 1" /> <telerik:AxisItem LabelText="Item 2" /> <telerik:AxisItem LabelText="Item 3" /> </Items> </XAxis> </PlotArea> </telerik:RadHtmlChart>