Search code examples
c#wpfdynamic-data-display

Both X and Y logarithmic D3


I'm using DynamicDataDisplay (I've tried with 0.3, 0.4 and futureD3 versions) but there is no way to set both axis to logarithmic scale and be able to activate and deactivate them. I know that D3 is almost abandoned but if anyone had this problem before it would to be nice hear a hint.

PD.Is there any free library that can plot simple 2D LineGraphs? (Zoom, Pan, Logarithmic scales, etc)


Solution

  • I found a file in the D3 folder with two log axes, it doesnt compile (I don't why) but I could set both axes logarithmic using its code:

     private void Window_Loaded_1(object sender, RoutedEventArgs e)
            {
                plotter.DataTransform = new Log10Transform();
    
                double[] xArray = new double[] { 15, 14, 16, 48, 50, 51 };
                double[] yArray = new double[] { 60, 63, 64, 124, 131, 144 };
    
                var xds = xArray.AsXDataSource();
                var yds = yArray.AsYDataSource();
                var ds = new CompositeDataSource(xds, yds);
    
                LineGraph hola = new LineGraph(ds);
                plotter.Children.Add(hola);
    
    
                HorizontalAxis xAxis = new HorizontalAxis
                {
                    TicksProvider = new LogarithmNumericTicksProvider(10),
                    LabelProvider = new UnroundingLabelProvider()
                };
                plotter.MainHorizontalAxis = xAxis;
    
                VerticalAxis yAxis = new VerticalAxis
                {
                    TicksProvider = new LogarithmNumericTicksProvider(10),
                    LabelProvider = new UnroundingLabelProvider()
                };
                plotter.MainVerticalAxis = yAxis;
            }