Changing Legend in the Future of Dynamic Data Disp

2019-08-12 12:18发布

问题:

I have been using the Future d3 but can not figure out how to change the series legend. In the older builds the legend could be changed like:

    graf = plotter.AddLineGraph(new CompositeDataSource(xSrc, plot),
                 new Pen(brush, 4),
                 new PenDescription("myText" ));

but here the function call to AddLineGraph takes an object as argument and hence one can not specify the pendescription... Please does anyone know how to do this? This question was asked before here but did not get any answers. Any help would be highly appreciated. I have spend a lot of time on this and dont want to change to any other library just because of this small issue...

回答1:

The above doesn't work with recent (2016) v0.4.0.

v0.4.0 uses the following syntax:

// For access to the Legend class
using Microsoft.Research.DynamicDataDisplay.Charts;

... snip ...
LineGraph lineGraph = new LineGraph(dataSource);
lineGraph.LinePen = new Pen(Brushed.Green, 1.0);
Legend.SetDescription(lineGraph, "The line label");
plotter.Children.Add(lineGraph);
... snip ...

v0.3.0 used the following syntax:

plotter.AddLineGraph(dataSource, pen, marker, new PenDescription("The line label"));

Ref: Changing and setting the Legend (LineGraph) Future of DynamicDataDisplay

Post http://d3future.codeplex.com/discussions/635917 provided the core fix.