Pre loader

how to draw graph

Welcome to the SciChart Forums!

  • Please read our Question Asking Guidelines for how to format a good question
  • Some reputation is required to post answers. Get up-voted to avoid the spam filter!
  • We welcome community answers and upvotes. Every Q&A improves SciChart for everyone

WPF Forums | JavaScript Forums | Android Forums | iOS Forums

0
0

Is it possible to draw a graph without passing values to other charts just by doing RenderableSeries.Add?
in WPF C#

Version
trial
  • You must to post comments
0
0

Yes,
you have to draw a graph in WPF by adding a RenderableSeries directly to the SciChartSurface, without passing values to other charts explicitly. Just create a DataSeries, add data points to it, create a RenderableSeries (e.g., LineRenderableSeries), set its data series, and add it to the RenderableSeries collection of the SciChartSurface.
That’s it – the graph will be displayed based on the provided data series.

using System.Windows;
using SciChart.Charting.Model.DataSeries;
using SciChart.Charting.Visuals;
using SciChart.Charting.Visuals.RenderableSeries;

public partial class MainWindow : Window
{
public MainWindow()
{
InitializeComponent();

    var sciChartSurface = new SciChartSurface();
    chartContainer.Children.Add(sciChartSurface);

    // Create a new XyDataSeries<double, double> to hold your data points
    var dataSeries = new XyDataSeries<double, double>();

    // Add data points to the data series (x, y) coordinates
    dataSeries.Append(1.0, 10.0);
    dataSeries.Append(2.0, 20.0);
    dataSeries.Append(3.0, 15.0);
    // Add more data points as needed...

    // Create a new LineRenderableSeries and add the data series to it
    var renderableSeries = new LineRenderableSeries()
    {
        DataSeries = dataSeries,
        Stroke = System.Windows.Media.Colors.Blue, // Set the line color
        StrokeThickness = 2                        // Set the line thickness
    };

    // Add the LineRenderableSeries to the SciChartSurface
    sciChartSurface.RenderableSeries.Add(renderableSeries);
}

}

  • You must to post comments
0
0

As far as I know, you can indeed create and draw a graph by using the RenderableSeries.Add method without explicitly passing values to other charts. However, to display any meaningful data on the graph, you still need to provide data points to the chart’s DataSeries before adding the RenderableSeries.

  • You must to post comments
Showing 2 results
Your Answer

Please first to submit.