I have made a Chart class. I give our third party software the ability to add series with tooltips. But the tooltips are not working.
The funny thing is, the tooltip works sometimes in the third party software. When I test it in a windows form, it never works...
What am I doing wrong?
Class:
public class DollarChart : System.Windows.Forms.DataVisualization.Charting.Chart
Initialization:
public void Wrapper_Init()
{
System.Windows.Forms.DataVisualization.Charting.ChartArea chartArea1;
System.Windows.Forms.DataVisualization.Charting.Series MySeries2;
chartArea1 = this.ChartAreas["ChartArea1"];
MySeries2 = this.Series["Series1"];
chartArea1.Name = "Default";
chartArea1.AxisY.IntervalAutoMode = System.Windows.Forms.DataVisualization.Charting.IntervalAutoMode.FixedCount;
chartArea1.AxisY.Enabled = System.Windows.Forms.DataVisualization.Charting.AxisEnabled.True;
chartArea1.AxisY2.IntervalAutoMode = System.Windows.Forms.DataVisualization.Charting.IntervalAutoMode.FixedCount;
// Invisible series in order to make room for primary Y-axis on chartarea.
MySeries2.Points.Add(0);
MySeries2.Points.Add(490);
MySeries2.Color = System.Drawing.Color.FromName("Transparent");
this.Name = "chart1";
}
Function for inserting data:
public void Wrapper_Populate(System.Single[] AvailDollars, int SeriesSplitter, int PlotHours)
{
System.Double[] Dollars;
Dollars = new System.Double[AvailDollars.Length];
AvailDollars.CopyTo(Dollars,0);
System.Double[] buffer;
buffer = new System.Double[SeriesSplitter];
System.Windows.Forms.DataVisualization.Charting.Series MySeries = new System.Windows.Forms.DataVisualization.Charting.Series();
MySeries.ChartType = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.StackedColumn;
Array.Copy(Dollars, 0, buffer, 0, SeriesSplitter); // Copies from the correct place in the array.
int n = 0;
foreach (double p in buffer)
{
System.Windows.Forms.DataVisualization.Charting.DataPoint Pointer = new System.Windows.Forms.DataVisualization.Charting.DataPoint();
Pointer.YValues[0] = p;
Pointer.ToolTip = "Testing123";
MySeries.Points.Add(Pointer);
if (n == (PlotHours-1)) { break; }
n++;
}
MySeries.Name = "Stacked_Dollars";
MySeries.YAxisType = System.Windows.Forms.DataVisualization.Charting.AxisType.Secondary;
this.Series.Add(MySeries);
The reason for setting tooltip per datapoint, is that I will be displaying a calculated total for all series and the value for the specific series in each datapoint. The reason for doing array.copy is that I receive the values neatly packed in a 600 element array, divided into sections for each series, in addition, I need to convert from System.Single to System.Double.
I'm sure you will be asking why I'm doing this. Were using third party software that uses something called quickscript.net. One of the things this third party software lacks, is charting. We are, however, able to import custom controls. So we have to work around the limitations by making what they call "Client controls" and "Script function library".