Similar to the RadChart's http://demos.telerik.com/aspnet-ajax/chart/examples/newfeatures/intelligentlabels/defaultcs.aspx For the time being you can implement a custom logic for offsetting y point positions of labels. For example offset every 2nd item label position: <telerik:RadScriptManager ID="RadScriptManager1" runat="server"></telerik:RadScriptManager> <script> function pageLoad() { offsetItemLabels(); } function offsetItemLabels() { //Find all text elements on the page var textElements = document.getElementsByTagName("text"); var numSeriesItemLabels = 0; //Iterate through the text elements for (var i = 0; i < textElements.length; i++) { var currTextEl = textElements[i]; //Set the desired string/symbol that represents the series labels var SeriesLabelSymbol = "@SL"; if (currTextEl.textContent.indexOf(SeriesLabelSymbol) != -1) { numSeriesItemLabels++; var currText = currTextEl.textContent.split(SeriesLabelSymbol); //Offset y point for every 2nd item label currTextEl.textContent = currText[1]; if ((numSeriesItemLabels) % 2 == 0) { currTextEl.attributes.y.textContent = currTextEl.attributes.y.textContent * 1 + 35; } } } } </script> <telerik:RadHtmlChart ID="RadHtmlChart1" runat="server" Width="600px" Height="400px"> <ChartTitle Text="Chart title"> </ChartTitle> <PlotArea> <Series> <telerik:LineSeries Name="Series 1"> <SeriesItems> <telerik:CategorySeriesItem Y="18" /> <telerik:CategorySeriesItem Y="18" /> <telerik:CategorySeriesItem Y="18" /> <telerik:CategorySeriesItem Y="18" /> </SeriesItems> <LabelsAppearance> <ClientTemplate> @SLCategory is #=category# Value is: #=value# </ClientTemplate> </LabelsAppearance> </telerik:LineSeries> </Series> <XAxis> <Items> <telerik:AxisItem LabelText="item 1" /> <telerik:AxisItem LabelText="item 2" /> <telerik:AxisItem LabelText="item 3" /> <telerik:AxisItem LabelText="item 4" /> </Items> </XAxis> </PlotArea> </telerik:RadHtmlChart>
For the time being the DateTime object can be set to the AxisCrossingPoint on the client. For example: ASPX: <script> function OnLoadHandler(sender, args) { var kendoChart = sender.get_kendoWidget(); var opts = kendoChart.options; opts.categoryAxis.axisCrossingValues = [0, new Date("2014, 11, 05, 19:15:00")]; kendoChart.setOptions(opts); } </script> <telerik:RadHtmlChart runat="server" ID="RadHtmlChart1" Width="600px" Height="400px"> <ClientEvents OnLoad="OnLoadHandler" /> <PlotArea> <Series> <telerik:LineSeries Name="Product 1" DataFieldY="SellQuantity"> </telerik:LineSeries> </Series> <XAxis DataLabelsField="SellDate" BaseUnit="Minutes"> <LabelsAppearance Step="15"></LabelsAppearance> <MinorGridLines Visible="false" /> <AxisCrossingPoints> <telerik:AxisCrossingPoint Value="10" /> </AxisCrossingPoints> </XAxis> <AdditionalYAxes> <telerik:AxisY></telerik:AxisY> </AdditionalYAxes> </PlotArea> <ChartTitle Text="LineSeries"></ChartTitle> </telerik:RadHtmlChart> C#: protected void Page_Load(object sender, EventArgs e) { if (!Page.IsPostBack) { 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(2014, 11, 05, 18, 22, 22)); dt.Rows.Add(2, 5, new DateTime(2014, 11, 05, 18, 56, 22)); dt.Rows.Add(3, 6, new DateTime(2014, 11, 05, 19, 14, 22)); dt.Rows.Add(4, 4, new DateTime(2014, 11, 05, 19, 48, 22)); dt.Rows.Add(5, 7, new DateTime(2014, 11, 05, 20, 12, 22)); return dt; }
Hi, MissingValue set to Gap or Zero doesn't work in RadHtmlChart with ScatterLineSeries. Interpolation is done instead. <telerik:RadHtmlChart runat="server"> <PlotArea> <Series> <telerik:ScatterLineSeries Name="Test" DataFieldX="XValue" DataFieldY="YValue" MissingValues="Gap"> <SeriesItems> <telerik:ScatterSeriesItem X="1" Y="8" /> <telerik:ScatterSeriesItem X="2" Y="9" /> <telerik:ScatterSeriesItem X="3" Y="4" /> <telerik:ScatterSeriesItem X="4" Y="6" /> <telerik:ScatterSeriesItem X="5" Y="7" /> <telerik:ScatterSeriesItem X="8" Y="1" /> <telerik:ScatterSeriesItem X="9" Y="5" /> <telerik:ScatterSeriesItem X="10" Y="4" /> </SeriesItems> </telerik:ScatterLineSeries> </Series> </PlotArea> </telerik:RadHtmlChart> The workaround described in the following link doesn't work either : https://feedback.telerik.com/Project/108/Feedback/Details/44399-fix-the-functionality-of-the-missingvalue-property-when-set-to-gap-in-areaserie Can you please fix this bug ? Thanks and regards.
When viewing a line chart with multiple series, the RadHtmlChart automatically changes shapes for each series to make it easy to distinguish, however the shapes are not carried over to the legend. This means a user printing on a black & white printer will have no way to distinguish the different series (since the shapes are not in the legend).
The feature will be similar to Plot Bands (see http://demos.telerik.com/aspnet-ajax/htmlchart/examples/functionality/plot-bands/defaultcs.aspx demo), however, the width of lines will not be dependent on the y-axis scale.
As of R1 2017 you can use the stackTotal property of the labels: https://docs.telerik.com/kendo-ui/controls/charts/how-to/various/show-stack-total --- old information For the time being this can be achieved by creating an additional bar/column series with the following settings: -series items are set with insignificantly small values (e.g. 0.001) -the name property of the series is not specified, so that it is not visible in the legend -the color of the series matches the color of the plot area, so that the series items and the legend of the series are not visible -clienttemplates for the labels of this series is used in order to sum up the grand total and display it An example on the described scenario can be found in the http://www.telerik.com/support/kb/aspnet-ajax/chart-%28html5%29/details/displaying-grand-total-in-stacked-series-labels-and-pie-series-legend KB article
So cool RadHtmlChart navigator should be able to be attached to non-stock layout charts, support multiple databound series and y-axis items other than financial data
There are two workarounds you can use in the meantime - Use string representations of the dates instead of actual dates. In this manner you can bind the chart to strings and use a "regular" categorical axis and then the plot bands will work based on the index of the item. In such a case you will need to aggregate the data yourself before passing it to the chart. - Using the Kendo Chart widget directly, and here is an example of using date objects and adding plot bands dynamically: https://docs.telerik.com/kendo-ui/controls/charts/how-to/appearance/dynamic-plot-bands Here is also a basic example of fetching the Kendo Chart scripts through a hidden RadHtmlChart so that you can easily use the Kendo Chart widget <script> var myData = [{ "day": new Date("2014/01/01") }, { "day": new Date("2014/01/02") }, { "day": new Date("2014/01/31") }]; function addPlotBand() { $ = $telerik.$; var start = new Date(2014, 0, 1 + Math.floor(Math.random() * 30)); var end = new Date(start.getTime() + 1000 * 3600 * 24); // 24 hours after start var options = {}; options["categoryAxis"] = { plotBands: [{ from: start, to: end, color: "green" }] }; $("#chart2").data("kendoChart").setOptions(options); } function pageLoad() { $ = $telerik.$; $("#chart2").kendoChart({ dataSource: { data: myData }, categoryAxis: { type: "date", field: "day" } }); } </script> <telerik:RadButton ID="RadButton1" runat="server" AutoPostBack="false" OnClientClicked="addPlotBand" Text="add plotband" /> <div id="chart2"></div> <telerik:RadHtmlChart runat="server" ID="chart" Style="visibility: hidden;"> <PlotArea> <XAxis DataLabelsField="day"> </XAxis> </PlotArea> </telerik:RadHtmlChart>
Currently there is some space between the PlotArea and the starting/ending points of the LineSeries in RadHtmlChart. To changethat behavior, so that it is similar to the one in AreaSeries the justified property (https://docs.telerik.com/kendo-ui/api/javascript/dataviz/ui/chart/configuration/categoryaxis.justified) can be set through the underlying Kendo Chart widget: <telerik:RadCodeBlock ID="RadCodeBlock1" runat="server"> <script> function onLoad(sender) { var chart = sender.get_kendoWidget(); var opts = chart.options; opts.categoryAxis.justified = true; chart.setOptions(opts); chart.redraw(); } </script> </telerik:RadCodeBlock> <telerik:RadHtmlChart runat="server" ID="LineChart" Width="800" Height="500" Transitions="true"> <ClientEvents OnLoad="onLoad" /> <PlotArea> <Series> <telerik:LineSeries Name="Week 15" MissingValues="Interpolate"> <SeriesItems> <telerik:CategorySeriesItem Y="15" /> <telerik:CategorySeriesItem Y="23" /> <telerik:CategorySeriesItem /> <telerik:CategorySeriesItem Y="71" /> <telerik:CategorySeriesItem Y="93" /> <telerik:CategorySeriesItem Y="43" /> <telerik:CategorySeriesItem Y="23" /> </SeriesItems> </telerik:LineSeries> </Series> </PlotArea> </telerik:RadHtmlChart>
For the time being the following workaround can be used: JavaScript: <script> function pageLoad() { var chart = $find("<%=RadHtmlChart1.ClientID%>"); chart._chartObject.options.series[0].missingValues = "Gap"; chart.repaint(); } </script> ASPX: <telerik:RadHtmlChart ID="RadHtmlChart1" runat="server"> <PlotArea> <Series> <telerik:LineSeries MissingValues="Gap"> <SeriesItems> <telerik:CategorySeriesItem Y="30" /> <telerik:CategorySeriesItem Y="10" /> <telerik:CategorySeriesItem /> <telerik:CategorySeriesItem Y="30" /> </SeriesItems> </telerik:LineSeries> </Series> </PlotArea> </telerik:RadHtmlChart>
LineBreak is not supported by SVG (more on that - http://www.w3.org/TR/SVG11/text.html#Introduction) and RadHtmlChart uses SVG to render in modern browsers. Add the ability to handle long label text in SVG as well. Currently long strings are getting clipped. For the time being the labels can be manually split in separate text elements. For example: <script> function pageLoad() { wrapLabels(); } function wrapLabels() { //Find all text elements on the page var textElements = document.getElementsByTagName("text"); //Iterate through the text elements for (var i = 0; i < textElements.length; i++) { var currTextEl = textElements[i]; //Set the desired string/symbol that represents the line break var lineBreakSymbol = "@LineBreak@"; if (currTextEl.textContent.indexOf(lineBreakSymbol) != -1) { var lines = currTextEl.textContent.split(lineBreakSymbol); //Adjust the x and y coordinates for the new text element from the old one var textAlignCoefficient = 7; var x = currTextEl.attributes.x.textContent * 1 + lines[1].length * textAlignCoefficient; var y = currTextEl.attributes.y.textContent * 1 + 20; //Obtain the same style for the new text element from the old one var style = currTextEl.attributes.style.textContent; //Add the new SVG text element addSVGTextElement(currTextEl, x, y, style, lines[1]); //Adjust the text and the position for the old text element currTextEl.textContent = lines[0]; currTextEl.attributes.x.textContent = currTextEl.attributes.x.textContent * 1 + lines[1].length * textAlignCoefficient; } } } function addSVGTextElement(placeHolder, x, y, style, text) { var newText = document.createElementNS("http://www.w3.org/2000/svg", "text"); newText.setAttributeNS(null, "x", x); newText.setAttributeNS(null, "y", y); newText.setAttributeNS(null, "style", style); var textNode = document.createTextNode(text); newText.appendChild(textNode); placeHolder.parentNode.insertBefore(newText, placeHolder); } </script> <telerik:RadHtmlChart ID="RadHtmlChart1" runat="server" Width="600px" Height="400px"> <ChartTitle Text="Chart title @LineBreak@ more text in title"> </ChartTitle> <PlotArea> <Series> <telerik:ColumnSeries Name="Series 1"> <SeriesItems> <telerik:CategorySeriesItem Y="30" /> <telerik:CategorySeriesItem Y="10" /> <telerik:CategorySeriesItem Y="20" /> </SeriesItems> <LabelsAppearance> <ClientTemplate> Category is #=category#@LineBreak@Value is: #=value# </ClientTemplate> </LabelsAppearance> </telerik:ColumnSeries> </Series> <XAxis> <Items> <telerik:AxisItem LabelText="item 1" /> <telerik:AxisItem LabelText="item 2" /> <telerik:AxisItem LabelText="item 3" /> </Items> </XAxis> </PlotArea> </telerik:RadHtmlChart>
In scenarios where the Series are Column/Bar and Positive and Negative values are present, the XAxis labels are overlapped by the Series themselves. Expose an additional Position property for the axis labels that controls their position to Top/Bottom. For the time being you can choose either approach: 1) Use a second x-axis that stores only the labels: a) Category Axis example: <script> function BottomXAxisLabels() { var chart = $find("<%=RadHtmlChart1.ClientID%>").get_kendoWidget(); var axis = $telerik.$.extend(true, {}, chart.options.categoryAxis); axis.line.visible = false; chart.setOptions({ categoryAxis: [{}, axis] }); chart.options.valueAxis.axisCrossingValues = [0, -99999999999]; chart.redraw(); } </script> <telerik:RadHtmlChart runat="server" ID="RadHtmlChart1" Width="600px" Height="400px"> <ClientEvents OnLoad="BottomXAxisLabels" /> <PlotArea> <Series> <telerik:ColumnSeries Name="Product 1"> <SeriesItems> <telerik:CategorySeriesItem Y="15000" /> <telerik:CategorySeriesItem Y="-4000" /> <telerik:CategorySeriesItem Y="10000" /> </SeriesItems> </telerik:ColumnSeries> </Series> <XAxis> <Items> <telerik:AxisItem LabelText="1" /> <telerik:AxisItem LabelText="2" /> <telerik:AxisItem LabelText="3" /> </Items> </XAxis> </PlotArea> <ChartTitle Text="Product sales for 2011"> </ChartTitle> <Legend> <Appearance Position="Bottom" /> </Legend> </telerik:RadHtmlChart> b) Numeric axis example: <script> function BottomXAxisLabels() { var chart = $find("<%=RadHtmlChart1.ClientID%>").get_kendoWidget(); var axis = $telerik.$.extend(true, {}, chart.options.xAxis); axis.line.visible = false; chart.setOptions({ xAxis: [{ labels: { visible: false }}, axis] }); chart.options.yAxis.axisCrossingValues = [0, -99999999999]; chart.redraw(); } </script> <telerik:RadHtmlChart runat="server" ID="RadHtmlChart1" Width="600px" Height="400px"> <ClientEvents OnLoad="BottomXAxisLabels" /> <PlotArea> <Series> <telerik:ScatterLineSeries Name="Product 1"> <SeriesItems> <telerik:ScatterSeriesItem Y="15000" X="5" /> <telerik:ScatterSeriesItem Y="-4000" X="6" /> <telerik:ScatterSeriesItem Y="10000" X="7"/> </SeriesItems> </telerik:ScatterLineSeries> </Series> </PlotArea> <ChartTitle Text="Product sales for 2011"> </ChartTitle> <Legend> <Appearance Position="Bottom" /> </Legend> </telerik:RadHtmlChart> 2) Use the TextStyle property of the RadHtmlChart , in order to set higher margin for the XAxis labels. For example: <telerik:RadHtmlChart ID="RadHtmlChart1" runat="server" Width="600px" Height="400px"> <PlotArea> <Series> <telerik:ColumnSeries Name="Product 1"> <SeriesItems> <telerik:CategorySeriesItem Y="15000" /> <telerik:CategorySeriesItem Y="-4000" /> <telerik:CategorySeriesItem Y="10000" /> </SeriesItems> </telerik:ColumnSeries> </Series> <XAxis> <LabelsAppearance> <TextStyle Margin="135 0 0 0" /> </LabelsAppearance> <Items> <telerik:AxisItem LabelText="item1" /> <telerik:AxisItem LabelText="item2" /> <telerik:AxisItem LabelText="item3" /> </Items> </XAxis> </PlotArea> </telerik:RadHtmlChart> Note: Labels margin and chart's PlotArea height are inversely proportional - the higher the margin is the lower the chart's PlotArea height will be. This resizing is needed, in order for the chart's main dimensions to be kept.
Currently the RadHtmlChart can be bound to a single data source. Add the ability to bind each series to a single data source.
Currently ClientTemplates are exposed only for the Series labels and tooltips. Improving this functionality will let you feed data for the legend from more than one column of the datasource as well as to format numbers and dates in the legend. The benefit will be essential for Pie and Donut series. For the time being the following workaround can be used: JavaScript: <script> function pageLoad() { var chart = $find("<%=RadHtmlChart1.ClientID%>"); chart._chartObject.options.legend.labels.template = "#=kendo.format(\'{0:d}\',dataItem.SellDate)#"; chart.repaint(); } </script> ASPX: <telerik:RadHtmlChart runat="server" ID="RadHtmlChart1" Width="640px" Height="480px"> <PlotArea> <Series> <telerik:PieSeries DataFieldY="SellQuantity" NameField="SellDate"> </telerik:PieSeries> </Series> </PlotArea> </telerik:RadHtmlChart>
For example by exposing an additional width property.
The feature should be like the one in KendoUI' https://docs.telerik.com/kendo-ui/api/javascript/dataviz/ui/chart#configuration-series.aggregate For the time being it can be set through the chartObject: ASPX: <telerik:RadScriptManager ID="RadScriptManager1" runat="server"></telerik:RadScriptManager> <script type="text/ecmascript"> function pageLoad() { var chart = $find("<%=RadHtmlChart1.ClientID%>"); chart._chartObject.options.series[0].aggregate = "sum"; chart.repaint(); } </script> <telerik:RadHtmlChart runat="server" ID="RadHtmlChart1" Width="640px" Height="480px"> <PlotArea> <Series> <telerik:LineSeries DataFieldY="SellQuantity"> </telerik:LineSeries> </Series> <XAxis BaseUnit="months" DataLabelsField="SellDate"> <LabelsAppearance DataFormatString="d"> </LabelsAppearance> </XAxis> </PlotArea> </telerik:RadHtmlChart> C#: using System.Data; 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(2012, 06, 12)); dt.Rows.Add(2, 5, new DateTime(2012, 06, 13)); dt.Rows.Add(3, 6, new DateTime(2012, 06, 17)); dt.Rows.Add(4, 4, new DateTime(2012, 07, 18)); dt.Rows.Add(5, 7, new DateTime(2012, 07, 20)); return dt; }
For the time being the following events can be handled through the chartObject. -drag event is fired when the plot area of the main chart is dragged. -zoom event is fired when the mouse wheel is used in the plot area of the main chart. -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 OnLoad(sender) { var chart = sender; chart._chartObject.bind("dragEnd", OnDragEnd); chart._chartObject.bind("selectEnd", OnSelectEnd); chart._chartObject.bind("zoom", OnZoom); } function OnDragEnd(e) { alert("OnDragEnd triggered: \nMin: " + e.axisRanges['mainAxis'].min + "\n Max: " + e.axisRanges['mainAxis'].max); } function OnSelectEnd(e) { alert("OnSelectEnd triggered: \nFrom: " + e.from + "\n To: " + e.to); } function OnZoom(e) { alert("OnZoom triggered: \nMin: " + e.axisRanges['mainAxis'].min + "\n Max: " + e.axisRanges['mainAxis'].max); } </script> </telerik:RadCodeBlock> ASPX: <telerik:RadHtmlChart runat="server" ID="RadHtmlChart1" Layout="Stock" Width="800" Height="400" Transitions="true"> <ClientEvents OnLoad="OnLoad" /> <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; }