Steema Issues Database

Note: 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.



Bug 801 - Same ValueLists for multiple series
Summary: Same ValueLists for multiple series
Status: CONFIRMED
Alias: None
Product: .NET TeeChart
Classification: Unclassified
Component: Series (show other bugs)
Version: TeeChart.NET 2014 4.1.2014.02060
Hardware: PC Windows
: --- enhancement
Target Milestone: ---
Assignee: Steema Issue Manager
URL: http://stackoverflow.com/questions/24...
Keywords:
Depends on:
Blocks:
 
Reported: 2014-06-16 10:30 EDT by narcís calvet
Modified: 2014-07-16 07:23 EDT (History)
0 users

See Also:
Chart Series: ---
Delphi / C++ Builder RAD IDE Version:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description narcís calvet 2014-06-16 10:30:45 EDT
Being able to use the same and unique ValueLists for multiple series so data doesn't need to be copied across. Different series could even be in different charts. See the StackOverflow discussion in the URL field.
Comment 1 narcís calvet 2014-07-16 07:23:13 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());
    }