“我正在使用Winrt Xaml工具包附带的图表。尽管有一些(xaml)错误,但大多数图表显示得很好。但是轴的神圣不起作用。当我试图定义一个min时,最大值或间隔值我得到以下错误:
无法从文本“1”创建“Windows.Foundation.IReference`1”
<charting:Chart x:Name="GradePointAverage" Title="Line Chart" Width="650" Height="650">
<charting:Chart.Axes>
<charting:LinearAxis Orientation="X" Title="x axis" Interval="1" Minimum="1" Maximum="6" />
<charting:LinearAxis Orientation="Y" Title="y axis" ShowGridLines="True" />
</charting:Chart.Axes>
<charting:LineSeries ItemsSource="{Binding Items}" IndependentValueBinding="{Binding HalfYear}"
DependentValueBinding="{Binding Average}" IsSelectionEnabled="True" AnimationSequence="FirstToLast" TransitionDuration="0:0:5" />
</charting:Chart>
此外,所有图表都标记为“类型[图表类型]的值无法添加到'collection`1'”类型的集合或字典中。我通过nuget安装了工具包,并且已经尝试重新安装。
答案 0 :(得分:1)
在xaml中设置最小值,最大值和间隔时,我也遇到了各种问题。但是能够通过在C#中进行修复来修复它。 这样的事情应该可行:(基于此:How to set axis margin in WinRT XAML Toolkit line chart?)
((LineSeries)GradePointAverage.Series[0]).IndependentAxis = new LinearAxis
{
Minimum = 1,
Maximum = 6,
Orientation = AxisOrientation.X,
Interval = 1
};
((LineSeries)GradePointAverage.Series[0]).DependentRangeAxis = new LinearAxis
{
Orientation = AxisOrientation.Y,
ShowGridLines = true
};