Changing and setting the Legend (LineGraph) Future of DynamicDataDisplay

白昼怎懂夜的黑 提交于 2019-12-24 07:01:47

问题


I'm using this great library https://d3future.codeplex.com/ to plot some 2D graphs.

In the old D3 I used to set the legend this way:

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

But I have no idea how to obtain the same in future D3. Could someone make me see the light?

Exploring the source code I find this but can't understand how to access and change the default string "LineGraph":

    public class LineGraph : PointsGraphBase
        {
            static LineGraph()
            {
                Type thisType = typeof(LineGraph);

                Legend.DescriptionProperty.OverrideMetadata(thisType, new FrameworkPropertyMetadata("LineGraph"));
                Legend.LegendItemsBuilderProperty.OverrideMetadata(thisType, new FrameworkPropertyMetadata(new LegendItemsBuilder(DefaultLegendItemsBuilder)));
            }
//more stuff

}

回答1:


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



回答2:


When you add line graph to the plotter (AddLineGraph(...)), one of the parameters is description string.




回答3:


WGW is Spot On! Thumbs Up from me.

I found that doing it a slightly different way was easier to understand:

<Page 

...

xmlns:d3="http://research.microsoft.com/DynamicDataDisplay/1.0"

... >

... 

<Grid Name="GridOne" Grid.Column="0" Grid.Row="0" Margin="13" />

</Page>

And the Code Behind:

using Microsoft.Research.DynamicDataDisplay.Charts;

...

ChartPlotter PlotterOne = new ChartPlotter();

// Add a Graph to One:
GridOne.Children.Add(PlotterOne);

LineGraph line = new LineGraph();
line.ProvideVisiblePoints = true;
line.Stroke = Brushes.Blue;
line.StrokeThickness = 1;
line.DataSource = GetDayDataSource();

Legend.SetDescription(line, "Today's Activity");

PlotterOne.Children.Add(line);

Hope this helps.



来源:https://stackoverflow.com/questions/16763989/changing-and-setting-the-legend-linegraph-future-of-dynamicdatadisplay

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