Silver charts axis intervals
I have a number of Silverlight charts开发者_JAVA技巧 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);
}
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)
精彩评论