这个问题并不新鲜:带有LinearAxis的图表只使用整数。很多答案都建议使用Interval,但如果我有最小值= 1和最大值= 100,Interval = 1,轴将有100个数字,数量太多。我想要的是对LinearAxis的自动间隔计算进行一些修改。因此,这里的解决方案发现Andrew Barrett:WinRT Xaml图表中的区间与UWP
后,我申请我的示例应用程序与他的代码:
class Report
{
public string months { get; set; }
public int countlent { get; set; }
}
public MainPage()
{
this.InitializeComponent();
LoadChartContents();
}
private void LoadChartContents()
{
List<Report> lstSource = new List<Report>();
lstSource.Add(new Report() { months = "1", countlent = 10 });
lstSource.Add(new Report() { months = "2", countlent = 15 });
lstSource.Add(new Report() { months = "3", countlent = 20 });
lstSource.Add(new Report() { months = "4", countlent = 10 });
lstSource.Add(new Report() { months = "5", countlent = 13 });
lstSource.Add(new Report() { months = "6", countlent = 18 });
lstSource.Add(new Report() { months = "7", countlent = 33 });
lstSource.Add(new Report() { months = "8", countlent = 41 });
lstSource.Add(new Report() { months = "9", countlent = 31 });
lstSource.Add(new Report() { months = "10", countlent = 21 });
lstSource.Add(new Report() { months = "11", countlent = 12 });
lstSource.Add(new Report() { months = "12", countlent = 37 });
(LineChart.Series[0] as LineSeries).DependentRangeAxis = new LineSeriesAxis();
(LineChart.Series[0] as LineSeries).ItemsSource = lstSource;
}
的XAML页面:
<Chart:Chart x:Name="LineChart" HorizontalAlignment="Center" Margin="5" Width="500">
<Chart:LineSeries Title="Chart Name" IndependentValuePath="months" DependentValuePath="countlent" />
</Chart:Chart>
每次我运行或调试应用程序它停止并显示App.gics页面
#if DEBUG && !DISABLE_XAML_GENERATED_BREAK_ON_UNHANDLED_EXCEPTION
UnhandledException += (sender, e) =>
{
if (global::System.Diagnostics.Debugger.IsAttached) global::System.Diagnostics.Debugger.Break();
};
#endif
我在用他的代码吗?我正在使用UWP和WinRTXamlToolkit.Controls.DataVisualization.Charting Toolkit。
什么是例外五? –
没有显示。 – Dant
你能启用第一次机会例外吗? –