【问题标题】:OxyPlot legend items managingOxyPlot 图例项目管理
【发布时间】:2015-10-26 07:41:16
【问题描述】:

有没有办法管理图例中的项目?我的意思是等式从图例中删除一些项目,但不从整个情节中删除?我知道情节中的每个系列都与图例中的一个项目相关联,但我想打破这个规则并仅将选定的系列放入图例中。

感谢您的请求。

【问题讨论】:

  • 如果您没有为系列(lineseries 等)指定标题,则它不会出现在图例中。
  • 啊,这是个好主意!非常感谢,我试试看。
  • 是的,谢谢,它解决了我的问题。

标签: wpf oxyplot


【解决方案1】:

如果您没有为系列指定标题(LineSeries 等),则它不会出现在图例中:

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
});

从 v2.0.1 开始,图例不会自动出现,并且所有 PlotModel.LegendXxx 成员已被删除。您现在必须手动添加一个图例:

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
});

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-05-01
    • 2021-12-06
    • 2011-10-04
    • 2019-11-24
    相关资源
    最近更新 更多