Hi all,
Hoping for some pointers / help.
I have a C# WinForms application that has four chart controls used to graphically show some analysis results.
I have the code working for each graph, however in an attempt to be more efficient & re-use code I've defined a code block to :-
- create the required series,
- extracts the data from a database & assigns the results to the appropriate series
- add the series to the chart
- customise the charts appearance.
All of the above is done dynamically as the data dies not exist at design time.
The working code I am looking to re-use is :-
I'd like to change the ChartName to a variable that I can pass each of the names to in order to re-use the code. Something like (note this does not work):-
Any ideas, hints, tips, etc on how-to pass a variable into the ChartName would be appreciated.
Cheers
J
Hoping for some pointers / help.
I have a C# WinForms application that has four chart controls used to graphically show some analysis results.
I have the code working for each graph, however in an attempt to be more efficient & re-use code I've defined a code block to :-
- create the required series,
- extracts the data from a database & assigns the results to the appropriate series
- add the series to the chart
- customise the charts appearance.
All of the above is done dynamically as the data dies not exist at design time.
The working code I am looking to re-use is :-
// Add both series to the chart.
ChartName.Series.AddRange(new Series[] { series1, series2 });
// Cast the chart's diagram to the XYDiagram type, to access its axes.
XYDiagram diagram = (XYDiagram)ChartName.Diagram;
I'd like to change the ChartName to a variable that I can pass each of the names to in order to re-use the code. Something like (note this does not work):-
var VChart = this.Controls.Find(ChartName, true);
// Add both series to the chart.
VChart.Series.AddRange(new Series[] { series1, series2 });
// Cast the chart's diagram to the XYDiagram type, to access its axes.
XYDiagram diagram = (XYDiagram)VChart.Diagram;
Any ideas, hints, tips, etc on how-to pass a variable into the ChartName would be appreciated.
Cheers
J