更改和设置DynamicDataDisplay的Legend(LineGraph)未来

时间:2013-05-26 21:47:48

标签: c# wpf dynamic-data-display

我正在使用这个很棒的库https://d3future.codeplex.com/来绘制一些2D图。

在旧的D3中我曾经用这种方式设置传奇:

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

但我不知道如何在 future D3 中获得相同的内容。有人能让我看到光明吗?

探索源代码我发现了这一点,但无法理解如何访问和更改默认字符串“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

}

3 个答案:

答案 0 :(得分:3)

v0.4.0 使用以下语法:

// 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 使用以下语法:

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

答案 1 :(得分:0)

当您将线图添加到绘图仪(AddLineGraph(...))时,其中一个参数是描述字符串。

答案 2 :(得分:0)

WGW是现货!我竖起大拇指。

我发现以稍微不同的方式进行操作更容易理解:

<Page 

...

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

... >

... 

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

</Page>

守则背后:

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

希望这有帮助。