如何在图表的y轴上设置最小/最大/间隔 - ColumnSeries
?
我在Windows 8.1 Store应用程序中使用WinRTXamlToolkit.Controls.DataVisualization.Charting
lib。
图表工作正常没有,但如果我尝试设置Minimum
,Maximum
或Interval
,则会失败并显示以下错误:"无法在属性上分配为可空类型最小值& #34;
<charting:Chart
x:Name="BarChart2"
Height="400"
Title="title"
Margin="0,0">
<charting:ColumnSeries
ItemsSource="{Binding items}"
IndependentValueBinding="{Binding Initials}"
DependentValueBinding="{Binding NumberOfVisits}"
IsSelectionEnabled="True" >
<charting:ColumnSeries.DependentRangeAxis>
<charting:LinearAxis
Orientation="Y"
Interval="1"
Minimum="2"
ShowGridLines="False"/>
</charting:ColumnSeries.DependentRangeAxis>
</charting:ColumnSeries>
</charting:Chart>
答案 0 :(得分:1)
您可以使用以下内容在代码中执行此操作:
((LineSeries)LineChart.Series[0]).DependentRangeAxis = new LinearAxis()
{
Maximum = 50,
Minimum = 30,
Orientation = AxisOrientation.Y,
Interval = 20,
ShowGridLines = true,
};