![]() | 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: | [TV52016721] Cloning a Chart copies the series to the destination chart, and it al... | ||
|---|---|---|---|
| Product: | VCL TeeChart | Reporter: | yeray alonso <yeray> |
| Component: | Series | Assignee: | yeray alonso <yeray> |
| Status: | RESOLVED FIXED | ||
| Severity: | enhancement | CC: | mertelmeyer |
| Priority: | Normal | ||
| Version: | unspecified | ||
| Target Milestone: | --- | ||
| Hardware: | All | ||
| OS: | All | ||
| Chart Series: | --- | Delphi / C++ Builder RAD IDE Version: | |
|
Description
yeray alonso
2014-05-26 06:57:11 EDT
Another customer suggested another workaround using a Dictionary to save the correlations between the axes in the original and destination charts. The customer uses this dictionary to set the Series and Axis properties in the tools in the destination chart. Worth to take a look at when implementing the fix. http://www.teechart.net/support/viewtopic.php?p=66163#p66163 Here the code: class procedure TTeeChartRenderer.cloneTools( const fromChart: TChart; const toChart: TChart ); var axisLookupDict: IDictionary<TChartAxis, TChartAxis>; toolIterator: TTeeCustomTool; copiedTool: TTeeCustomTool; begin Assert( Assigned(fromChart) and Assigned(toChart) ); // This is a lookup dictionary to find the matching axis of "toChart" // when we still have the "old" axis of "fromChart" axisLookupDict := createAxisDictionary(fromChart, toChart); for toolIterator in fromChart.Tools do begin copiedTool := VclTee.Chart.CloneChartTool(toolIterator, toChart); // Point tool to matching series of toChart if toolIterator is TTeeCustomToolSeries then (copiedTool as TTeeCustomToolSeries).Series := toChart.Series[ (toolIterator as TTeeCustomToolSeries).Series.SeriesIndex ]; // Point tool to matching axis of toChart if toolIterator is TTeeCustomToolAxis then (copiedTool as TTeeCustomToolAxis).Axis := axisLookupDict[ (toolIterator as TTeeCustomToolAxis).Axis ]; toChart.Tools.Add(copiedTool); end; end; class function TTeeChartRenderer.createAxisDictionary( const originalChart: TChart; const clonedChart: TChart ): IDictionary<TChartAxis, TChartAxis>; var axisIndex: Integer; begin Assert( Assigned(originalChart) and Assigned(clonedChart) ); Result := TDictionary<TChartAxis, TChartAxis>.Create(); try {TODO -oJM -cGeneral : Does that that also include "custom axes"?} for axisIndex := 0 to Pred(originalChart.Axes.Count) do Result.Add( originalChart.Axes.Items[axisIndex], clonedChart.Axes.Items[axisIndex] ); except Result.Free(); raise; end; end; |