![]() | Steema Issues DatabaseNote: This database is for bugs and wishes only. For technical support help, if you are a customer please visit our online forums;otherwise you can use StackOverflow. Before using this bug-tracker we recommend a look at this document, Steema Bug Fixing Policy. |
| Summary: | Same ValueLists for multiple series | ||
|---|---|---|---|
| Product: | .NET TeeChart | Reporter: | narcís calvet <narcis> |
| Component: | Series | Assignee: | Steema Issue Manager <issuemanager> |
| Status: | CONFIRMED --- | ||
| Severity: | enhancement | ||
| Priority: | --- | ||
| Version: | TeeChart.NET 2014 4.1.2014.02060 | ||
| Target Milestone: | --- | ||
| Hardware: | PC | ||
| OS: | Windows | ||
| URL: | http://stackoverflow.com/questions/24169783/automation-processes-using-list-of-commands#comment37381171_24169783 | ||
| Chart Series: | --- | Delphi / C++ Builder RAD IDE Version: | |
|
Description
narcís calvet
2014-06-16 10:30:45 EDT
Revisiting this issue, while it is true that the same series object cannot be added to two different charts, it is also true that the same Arrays can be used by two series each in two different charts, e.g.:
double[] XValues, YValues;
private void button1_Click(object sender, EventArgs e)
{
YValues[1] = 7;
ModifySeries(tChart1[0]);
ModifySeries(tChart2[0]);
}
private void InitializeChart()
{
tChart1.Aspect.View3D = false;
tChart2.Aspect.View3D = false;
XValues = new double[] { 1, 2 };
YValues = new double[] { 1, 2 };
AddNewSeries(tChart1);
AddNewSeries(tChart2);
}
private void ModifySeries(Series series)
{
series.YValues.Modified = true;
series.XValues.Modified = true;
series.Invalidate();
}
private void AddNewSeries(TChart tChart)
{
FastLine series1 = new Steema.TeeChart.Styles.FastLine(tChart.Chart);
series1.YValues.Value = YValues;
series1.YValues.Count = YValues.Length;
series1.XValues.Value = XValues;
series1.XValues.Count = XValues.Length;
}
would only need to modify one set of arrays and then call ModifySeries for each of his series to propagate the new data through all of his charts. Is this sufficient?
The trick here is that, as it says at http://msdn.microsoft.com/en-us/library/9b9dty7d.aspx, "Array types are reference types derived from the abstract base type Array." As reference types (http://msdn.microsoft.com/en-us/library/490f96s2.aspx), "two variables can reference the same object; therefore, operations on one variable can affect the object referenced by the other variable.". This can be seen with this example:
double[] Array, CopyArray;
private void InitializeChart()
{
Array = new double[] { 1, 2 };
CopyArray = Array;
}
private void button1_Click(object sender, EventArgs e)
{
Array[1] = 7;
MessageBox.Show(CopyArray[1].ToString());
}
|