This thread looks to be a little on the old side and therefore may no longer be relevant. Please see if there is a newer thread on the subject and ensure you're using the most recent build of any software if your question regards a particular product.
This thread has been locked and is no longer accepting new posts, if you have a question regarding this topic please email us at support@mindscape.co.nz
|
Hi, I've just started using the phone elements controls and I'm struggling to get to grips with the working with a datetime axis. I'd like to be able to display an axis which starts at the first of the month and then has an interval of the first of the month every month after that. Is there anyway of doing this?
I've tried specifying a Minimum and Maximum on the axis in the xaml and code, but they are getting ignored. I've also tried binding the Interval to my view model which specifies the interval of 30days in ticks, but this caused an exception.
Do you have any examples of how I could achieve this? Thanks.
|
|
|
Hello At the moment we don't have a sample for this senario in PhoneElements, but you can find a sample in the free trial of WPF Elements: http://www.mindscapehq.com/products/wpfelements/download.The ChartingSampleExplorer project has a sample of this on the CustomAxisScale page. This also works in PhoneElements. Here is how to achieve it: Create a class to store the data for a single data point. This should simply contain a DateTime property (to map to the X axis) and a double property (to map to the Y axis). I'll call this DateTimeDouble. Here is a summery of what the XAML could look like: <ms:MonthAxisValueConverter x:Key="MonthConverter" />
<ms:Chart Name="Chart2" Margin="20" Title="Month scale" Grid.Column="1"> Please let us know if you need further help with this. |
|
|
Hi Jason, Thanks for the reply. That fixed the display of the months on the Axis, but its not quite what I wanted. I have the following dataset
[
{ Data = 84, Label = "09/07/2011" }, { Data = 78, Label = "03/08/2011" }, { Data = 68, Label = "17/08/2011" }, { Data = 73, Label = "28/08/2011" }, { Data = 78, Label = "22/09/2011" } ]
Where the Y axis will display the Label (date) and X axis the Data point So I want the axis to display: 3 labels, 1st Jul, 1st Aug, 1st Sep And then for the data points on the graph to displayed within the Y axis timeline on the date they occur on, but your graphs seems to want to evently space out all the data points, but for datetimes that are not evently spaced this makes no sense. |
|
|
Hello Sorry I didn't realize your actual data would be made up of both months and days. The MonthAxisValueConverter only has monthly precision and doesn't know about days which is why the data is being evenly spaced. For this kind of data you can use the DateTimeAxisValueConverter instead. This has precision right down to milliseconds which will display your data exactly as it is. The problem now is that if you want the axis to display the 1st of each month, the tick marks and axis labels would need to have different spacing. This is because different months have a different number of days. Unfortunatly our chart axes only supports evenly spaced tick marks. The best you can get is by setting the tick spacing to be some number of days (such as 30 as you mentioned before). When using the DateTimeAxisValueConverter, you can set the tick spacing in code by creating a new TimeSpan object and then setting the MajorTickSpacing property of the axis to be the Ticks property of that TimeSpan. Let us know what you think |
|