public void UpdateGraph()
{
zedGraphControl.GraphPane.Title.Text = scatterplot.Title;
zedGraphControl.GraphPane.XAxis.Title.Text = Scatterplot.XAxisTitle;
zedGraphControl.GraphPane.YAxis.Title.Text = Scatterplot.YAxisTitle;
classes.Clear();
if (scatterplot.Classes != null)
{
if (scatterplot.Classes.Count == 0)
{
zedGraphControl.GraphPane.Legend.IsVisible = false;
// Create space for unlabelled data
PointPairList list = new PointPairList(scatterplot.XAxis, scatterplot.YAxis);
LineItem item = new LineItem(String.Empty, list, Color.Black, SymbolType.Default);
item.Line.IsVisible = LinesVisible;
item.Symbol.Border.IsVisible = false;
item.Symbol.Fill = new Fill(Color.Black);
if (SymbolSize == 0)
item.Symbol.IsVisible = false;
else item.Symbol.Size = SymbolSize;
classes.Add(item);
}
else
{
zedGraphControl.GraphPane.Legend.IsVisible = true;
var colors = new ColorSequenceCollection(scatterplot.Classes.Count);
// Create a curve item for each of the labels
for (int i = 0; i < scatterplot.Classes.Count; i++)
{
// retrieve the x,y pairs for the label
double[] x = scatterplot.Classes[i].XAxis;
double[] y = scatterplot.Classes[i].YAxis;
PointPairList list = new PointPairList(x, y);
LineItem item = new LineItem(scatterplot.Classes[i].Text,
list, colors[i], SymbolType.Default);
item.Line.IsVisible = LinesVisible;
item.Symbol.Border.IsVisible = false;
item.Symbol.Fill = new Fill(colors[i]);
if (SymbolSize == 0)
item.Symbol.IsVisible = false;
else item.Symbol.Size = SymbolSize;
classes.Add(item);
}
}
zedGraphControl.AxisChange();
zedGraphControl.Invalidate();
zedGraphControl.RestoreScale(zedGraphControl.GraphPane);
if (!ScaleTight)
{
zedGraphControl.ZoomPane(zedGraphControl.GraphPane, 1.1, PointF.Empty, false);
}
}
}