Linking a chart to data on spread

Posted by: tomhouser on 8 September 2017, 3:12 pm EST

  • Posted 8 September 2017, 3:12 pm EST

    I would like my chart to take its data directly from the spreadsheet, for instance my line chart should display the numbers from from a certain region of cells. How can I accomplish this?
  • Replied 8 September 2017, 3:12 pm EST


    Please refer to the following documenattion links and you would be guided to create Chart using data from your Spread :

  • Replied 8 September 2017, 3:12 pm EST

    Thanks Mohita, that helps. But I've found it inadequate for fully specifying an XYPointPlot type of chart that I'm trying to build. So I thought maybe I could go about it another way:

    XYPointSeries ss = new XYPointSeries();
    ss.XValues.DataSource = "$F$3:$F$30";
    ss.YValues.DataSource = "$D$3:$D$30";

    SpreadChart chart = new SpreadChart(typeof(XYPointSeries), ChartViewType.View2D,new Point(0,0), new Size(500,500));//s.AddChart(new CellRange(0, 0, 1, 1), typeof(XYPointSeries), 600, 600, 0, yLocation);

    chart.Model.PlotAreas.Add(new XYPlotArea());
    chart.Model.PlotAreas[0].Location = new PointF(.1f, .1f);
    chart.Model.PlotAreas[0].Size = new SizeF(.9f, .9f);

    This code displays a blank chart even though the range specified in the DataSource properties of the Series object are filled with data. If I instead use the commented out code to manually add numbers, the chart does display that data. Can you help me do what I'm trying to do? Thanks!
  • Replied 8 September 2017, 3:12 pm EST

    Let me answer my own question, which I figured out by browsing at runtime what simpler line series looked like in charts, and how they ultimately connect with data on the spread:

    Set a series' value's datasource to a SeriesDataField object, and in the SeriesDataField constructor, specify the formula which describes the sheet and cell range which is the source of that value.
Need extra support?

Upgrade your support plan and get personal unlimited phone support with our customer engagement team

Learn More

Forum Channels