Margin between different series ploted in Live Charts Wpf

巧了我就是萌 提交于 2020-12-14 06:31:12

问题


I have plotted different series in basic column chart of live charts. but they are too close too each other. can i give some margin between them ? Also it doesn't show title of each series ?

    for (int i=0; i< _saleInvoiceList.Count;i++)
    {
      _seriesCollection.Add( new ColumnSeries
      {
         Title = _saleInvoiceList[i].SOType,
          DataLabels = true,
          Foreground = new SolidColorBrush(Color.FromRgb(254,24,24)),
          Values = new ChartValues<int>{_saleInvoiceList[i].Total},
            //Fill = PickBrush(),
            Margin = new Thickness(30,0,0,0)
      });

    DailySalesBarChart.LegendLocation = LegendLocation.Bottom;
    DailySalesBarChart.Series = _seriesCollection;  


回答1:


It’s showing the series title in the legend. If you want a label for each column, AFAIK you need to use a single series, cf. my other answer.

You can set the property ColumnPadding on your series to create some space between columns.

For all ColumnSeries in the XAML, probably the best place:

<Style TargetType="lvc:ColumnSeries">
    <Setter Property="ColumnPadding" Value="16"/>
</Style>

or for individual series:

_seriesCollection.Add(new ColumnSeries
{
    //your other settings
    , ColumnPadding = 16
});

If you only have one series, this will put 16 pixels between all columns. If you have multiple series, it will put 16 pixels between the series and 32 (twice the padding) between the data points (in your example you only have one point per series).



来源:https://stackoverflow.com/questions/55982406/margin-between-different-series-ploted-in-live-charts-wpf

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!