0
我正在使用WPF MVVM Live Charts,当我有巨大的负值时,它会将起点更改为大负值。我想知道是否有一个设置,我可以始终从0开始。WPF MVVM Live Charts设置行系列的起点
示例如下图所示。它是在-1,000,000开始每行而不是0
我的C#代码
private string[] _customerLabels;
public string[] CustomerLabels
{
get { return _customerLabels; }
set { SetProperty(ref _customerLabels, value); }
}
private SeriesCollection _customerSalesData;
public SeriesCollection CustomerSalesData
{
get { return _customerSalesData; }
set { SetProperty(ref _customerSalesData, value); }
}
private void PopulateCustomerGraph()
{
var seriesCollectionRowSales = new SeriesCollection();
var rowSeriesSales = new RowSeries();
var rowValuesSales = new ChartValues<double>();
var groupedData = BackLogListing
.GroupBy(m => m.CustomerId)
.Select(m => new
{
Key = m.Key,
Sales = m.Sum(x => x.Sales)
})
.OrderByDescending(m => m.Key);
CustomerLabels = groupedData.Select(m => m.Key).ToArray();
rowValuesSales.AddRange(groupedData.Select(m => (double)m.Sales).ToArray());
rowSeriesSales.Title = "Sales by Customer";
rowSeriesSales.Values = rowValuesSales;
seriesCollectionRowSales.Add(rowSeriesSales);
CustomerSalesData = seriesCollectionRowSales;
}
我的XAML
<lvc:CartesianChart Name="SalesByCustomer"
Series="{Binding CustomerSalesData}"
DataClickCommand="{Binding ShowCustomerDetailsCommand}"
LegendLocation="None"
MinHeight="500"
Margin="15">
<lvc:CartesianChart.AxisX>
<lvc:Axis Title="Dollars"
LabelFormatter="{Binding DollarsFormatter}">
<lvc:Axis.Separator>
<lvc:Separator IsEnabled="True"></lvc:Separator>
</lvc:Axis.Separator>
</lvc:Axis>
</lvc:CartesianChart.AxisX>
<lvc:CartesianChart.AxisY>
<lvc:Axis Title="Customers"
Labels="{Binding CustomerLabels}">
<lvc:Axis.Separator>
<lvc:Separator IsEnabled="True"
Step="1"></lvc:Separator>
</lvc:Axis.Separator>
</lvc:Axis>
</lvc:CartesianChart.AxisY>
<lvc:CartesianChart.DataTooltip>
<lvc:DefaultTooltip SelectionMode="SharedYValues"></lvc:DefaultTooltip>
</lvc:CartesianChart.DataTooltip>
</lvc:CartesianChart>
你能包括一些代码吗?它很难在黑暗中找到灯开关。 –
@BenderBending我已经包含了我的C#和XAML。为了简洁起见稍微减少,请让我知道如果你需要看到更多。谢谢。 –