Link to home
Start Free TrialLog in
Avatar of mcs26
mcs26

asked on

C# Reference Chart Series on userform from another class

Hi,

I'm just learning c# so believe this should not be to hard.

I have a chart on a form which when loaded a new Series called "PriceData" is created, please see the code below.

My problem is I have a class say called Class1 and I am trying to reference the Series called "PriceData" on the chart but cannot.

Any help would be great.

Thanks,

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Windows.Forms.DataVisualization.Charting;

namespace WindowsFormsApplication2
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
chartFXPair.ChartAreas.Clear();
chartFXPair.Series.Clear();
chartFXPair.Titles.Add("Blah");
ChartArea cArea = new ChartArea("Area");
cArea.AxisX.Minimum = 3;
cArea.AxisX.Maximum = 5;
cArea.AxisY.Minimum = 0;
cArea.AxisY.Maximum = 100;
chartFXPair.ChartAreas.Add(cArea);
Series seriesPrice = new Series("PriceData");
seriesPrice.ChartType = SeriesChartType.Line;
seriesPrice.ChartArea = "Area";
chartFXPair.Series.Add(seriesPrice);
seriesPrice.Points.AddXY(1, 50);
seriesPrice.Points.AddXY(2, 25);
seriesPrice.Points.AddXY(3, 70);
seriesPrice.Points.AddXY(4, 40);
}

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of AJRDev
AJRDev
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial