1

I have been using the version of D3 available in http://d3future.codeplex.com/

It has been working well with stock charts but gives an error at AddLineGraph. The code below comes from other web posts.

It appears that some versions of DynamicDataDisplay.dll available(v2/v3/v4) work/compile with that statement.

Any help would be greatly appreciated.

public partial class MainWindow : Window
{
    public ObservableDataSource<Point> source1 = null;
    public MainWindow()
    {
        InitializeComponent();
        //this.Loaded += MainWindow_Loaded;
    }

    private void Window_Loaded(object sender, RoutedEventArgs e)
    {
        source1 = new ObservableDataSource<Point>();
        //Set identity mapping of point
        source1.SetXYMapping(p => p);

        plotter3.AddLineGraph(source1, 4, "Data Row");

        //Fits the chart within ViewPort
        plotter3.Viewport.FitToView();

        // Start computation in 2nd thread
        Thread simThread = new Thread(new ThreadStart(Computation));
        simThread.IsBackground = true;
        simThread.Start();
    }
}
Floern
  • 33,559
  • 24
  • 104
  • 119
  • Error is 'ChartPlotter' does not contain a definition for AddLineGraph and no extension method 'AddLineGraph' accepting a first argument of type'ChartPlotter could be found'. – Mano Appapillai Mar 09 '16 at 23:20

4 Answers4

1

Try AddLineChart. I don't know why it's changed:

var x = Enumerable.Range(0, 9).Select(i => i * 100.0);
var y = new double[] { 10, 9, 7, 8, 5, 6, 4, 3, 2, 1 };
var source = DataSource.Create(x,y);
var line = plotter.AddLineChart(source)
    .WithStroke(Brushes.Red)
    .WithStrokeThickness(2)
    .WithDescription("x vs y");
jbriggs
  • 353
  • 2
  • 10
0

This may help you, Note here Point is type of elements in your Collection and Collection is your collection of enumerable data points.

var ds = new EnumerableDataSource<Point>(Collection);
LineGraph line;
ds.SetXMapping(x => x.X);
ds.SetYMapping(y => y.Y);
line = new LineGraph(ds);
line.LinePen = new System.Windows.Media.Pen(System.Windows.Media.Brushes.Red, 2);
//line.Description = new PenDescription("description");
Graph.Children.Add(line);
Graph.FitToView();
Yog
  • 112
  • 12
0

Thank you all for the helpful responses.

After much tinkering around(yes I am a beginner), I found that adding 5 cs files to the Project and using the DynamicDataDisplay.dll(56kb)available at the D3Future source site enabled the code run as originally posted. The five files were:: [1] Plotter2D [2] Plotter2DExtensions [3] Description [4] StandardDescription [5] PenDescription

I do not need Legends and Descriptions for now, so I commented out references to that, just to get the code to compile and run with the AddLineGraph method.

I am using Windows 10/Visual Studio Community Edition 2015.

Thank You.

0

I agree, why change this and pay extra special attention to NOT update all of the Source Code or Documentation.

On the other hand a standardisation is being adopted:

<Window

...

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

...

>

<d3:ChartPlotter Name="plotter" Margin="0,5,0,0">
<d3:LineGraph Name="lineGraph" Stroke="Red" StrokeThickness="1"/>
</d3:ChartPlotter>

</Window>

And in the Code Behind:

public MainWindow()
{

InitializeComponent();

plotter.Viewport.Domain = new Rect(-1, -1.2, 20, 2.4);
plotter.Children.Add(new HorizontalScrollBar());
plotter.AxisGrid.DrawHorizontalMinorTicks = false;
plotter.AxisGrid.DrawVerticalMinorTicks = false;

}




private void Window_Loaded(object sender, RoutedEventArgs e)
{

lineGraph.DataSource = CreateSineDataSource(1.0);

}   




private IPointDataSource CreateSineDataSource(double phase)
{

const int N = 100;

Point[] pts = new Point[N];

for (int i = 0; i < N; i++)
{
double x = i / (N / 10.0) + phase;
pts[i] = new Point(x, Math.Sin(x - phase));
}

var ds = new EnumerableDataSource<Point>(pts);
ds.SetXYMapping(pt => pt);

return ds;

}

Which is a snippet from the Documentation that does show this standardisation, but tidied up and minimised to show the Building Block Line Graph. Found Here: http://d3future.codeplex.com/SourceControl/latest#Main/src/DevSamples/LineTestSample/Window1.xaml.cs Version: 0.4

Notice the use of DataSource.

Hope this helps!

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