6

is there any way to manage items in legend? I mean e.q. remove some items from legend but not from whole plot? I know that each serie in plot is linked with one item in legend, but i want to break this rule and put to legend only selected series.

Thanks for your request.

Shadow2334
  • 111
  • 1
  • 1
  • 6

1 Answers1

20

If you don't assign a title to the series (LineSeries, etc), it won't be represented on the legend:

var plotModel = new PlotModel();
plotModel.LegendTitle = "Legend";
plotModel.LegendPosition = LegendPosition.RightBottom;

plotModel.Series.Add(new LineSeries
{
    ItemsSource = someItemSource,
    Color = OxyColors.Red,
    //Title = "title" <- Title commented
});

Starting v2.0.1, the legend doesn't automatically appear and all PlotModel.LegendXxx members have been removed. You now have to manually add one legend:

var plotModel = new PlotModel();
plotModel.Legends.Add(new Legend() { 
    LegendTitle = "Legend",
    LegendPosition = LegendPosition.RightBottom,
});

plotModel.Series.Add(new LineSeries
{
    ItemsSource = someItemSource,
    Color = OxyColors.Red,
    //Title = "title" <- Title commented
});
user276648
  • 6,018
  • 6
  • 60
  • 86
Jose
  • 1,857
  • 1
  • 16
  • 34