I'm trying to put together a line chart showing transactions per day over a period of time, separated out by store. I noticed that the dates on the X-axis are not correct when compared to the actual data. The dates on the bottom of the page don't scale, (instead it just uses each date point, so a hash mark can be one day, then jump to a week) and rather than place the datapoint at the right date, it just places it on the next one over.
When I set the DataXColumn setting for some hardcoded series, it worked fine. So, is there a way to set the DataXColumn for each series and have the chart display the correct dates? My code is below.
Some sample data:
40513 S-2 1
40518 S-2 2
40519 S-2 1
40549 S-2 4
40553 S-2 3
8 Answers, 1 is accepted
The bottom X-axis isn't scaling, it just has different hash marks corresponding to different data point's dates and the datapoints aren't matching up with the right date.
And my XAxis works awesome. Now, my only problem is getting the created series to use the dates as the X Column and not just put them in the order the datasource returns.
I tried using the DataManager.ValuesXColumn but that seems to have no effect. I'll keep plugging away, but this is much harder than I thought it would be.
RadChart treats your dates as categories because you are mapping your DateTime column to the DataLabelsColumn property of the Axis-X. If you map it to the DataXColumn the dates will appear normally. You can set the DataXColumn on the series like this:
Series are mapped to data as it is set to the datasource. RadChart doesn't sort your data, so you have to sort your data by the date column that your axis-X is mapped to prior to setting it to the datasource. You can do this using SQL in your query or perhaps you can do it in code behind using LINQ. Feel free to choose the approach that suits you best.
I have attached a small sample project that demonstrates how to bind RadChart to a collection of objects using DateTime as value for X-axis.
Hope this helps!
All the best,
the Telerik team
The solution turned out to be the DataManager:
It had to be done in the DataBinding for it to work, but now everything works properly.
When I have time, I'll post my full solution.
The DataGroupColumn sets the grouping, which creates series based on the Store.
I'm adding some DrillDown behavior to the chart. I have PointMarks implemented on the Line Chart.
If I click on the legend, the OnClick method is called and everything works.
If I click on the pointmarks, it throws an exception without even going to the OnClick. Here's the exception:
We are unable to define the state of the problem from this stack trace. Could you open a Support thread and send us the sample project attached where this issue occurs so that we will be able to investigate it and help you?
the Telerik team
I was calling RemoveAllSeries() in the Page_Load section, when it should be in the Chart onClick event handler.
Thanks a lot.