2

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;  

enter image description here

Hammas
  • 1,126
  • 1
  • 12
  • 37
  • Possible duplicate. You can find more information here: https://stackoverflow.com/questions/38731985/how-customize-column-width-in-column-series – Michael280 May 08 '19 at 13:06
  • @Michael280 no it's not duplicate ! that question is about width and i am asking about margin cuz margin is not working while width property works fine ! – Hammas May 09 '19 at 03:01

1 Answers1

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).

BenderBoy
  • 346
  • 2
  • 8