1

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

}
Sturm
  • 3,968
  • 10
  • 48
  • 78

3 Answers3

3

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"));
WGW
  • 29
  • 4
0

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

bor
  • 658
  • 7
  • 19
0

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.

Rusty Nail
  • 2,692
  • 3
  • 34
  • 55