Reputation: 1019
I have a number of Silverlight charts bound to datasets.
They all are working correctly however the values on the Axis display for years are showing, rather than full years, the points in between for example: 2007, 2007.2,2007.4 etc etc.
How can I make it so that it only show the full years?
Below is a screen shot to further explain visually what I mean.
Here is the code I use to bind the chart data:
foreach (var myVariable in UserSelections.TheDataSet.ER_Variables)
{
var newSeries = new LineSeries
{
ItemsSource =
UserSelections.GetDataRowsByVariableAndLocation(
UserSelections.GetIdForLocation(UserSelections.Locations[0]),
myVariable.Variable_ID),
IndependentValueBinding = new Binding("Year"),
DependentValueBinding = new Binding("Value"),
Title = myVariable.Name,
IsSelectionEnabled = true
};
MainChart.Series.Add(newSeries);
}
Upvotes: 2
Views: 1166
Reputation: 137128
In the chart definition you need the following:
<toolkit:Chart Title="Chart Title" VerticalAlignment="Top">
<toolkit:Chart.Axes>
<toolkit:DateTimeAxis IntervalType="Years" Interval="1"/>
</toolkit:Chart.Axes>
I think this should do the trick (assuming that your date is actually a DateTime
variable).
The key is you need to set the Interval
.
(Thanks to AnthonyWJones for pointing that out)
Upvotes: 5