I create the chart with the code below. The environment is Windows 2003
server with the .Net framework 1.1 version. Coded in c# in Visual Studio
..Net 2003.
string[][] SCIData = new string[4][];
// preload arrays
for (int SCILoop = 0; SCILoop < SCIData.Length; SCILoop++)
{
SCIData[SCILoop] = new string[5];
for (int QtrLoop = 0; QtrLoop < SCIData[SCILoop].Length; QtrLoop++)
{
SCIData[SCILoop][QtrLoop] = "0";
}
}
SqlDataReader dr =
Globals.SqlHelper.ExecuteReader(Globals.AppSettings.ConnectionString,
"spSplash_SCI", oSecurity.ReportFiscalYear, oSecurity.SecurityInfo.UserID);
while (dr.Read())
{
SCIData[dr.GetInt32(1) - 1][dr.GetInt32(0) - 1] = dr.GetValue(2).ToString();
}
dr.Close();
string QuarterNames = "Q1\tQ2\tQ3\tQ4\tYTD";
string SecureSeries = string.Join("\t", SCIData[0]);
string FavorableSeries = string.Join("\t", SCIData[1]);
string IndifferentSeries = string.Join("\t", SCIData[2]);
string AtRiskSeries = string.Join("\t", SCIData[3]);
OWC11.ChartSpace oChartSpace = new OWC11.ChartSpaceClass();
OWC11.ChChart oChart = oChartSpace.Charts.Add(0);
oChart.Type = OWC11.ChartChartTypeEnum.chChartTypeColumnClustered;
oChart.HasTitle = true;
oChart.Title.Caption = "Loyalty Hierarchy";
oChart.HasLegend = true;
oChart.Axes[1].Scaling.Minimum = 0;
oChart.Axes[1].HasTitle = true;
oChart.Axes[1].Title.Caption = "Percent";
oChart.SeriesCollection.Add(0);
oChart.SeriesCollection[0].SetData(OWC11.ChartDimensionsEnum.chDimCategories
, (int)OWC11.ChartSpecialDataSourcesEnum.chDataLiteral, QuarterNames);
oChart.SeriesCollection[0].SetData(OWC11.ChartDimensionsEnum.chDimSeriesName
s, (int)OWC11.ChartSpecialDataSourcesEnum.chDataLiteral, "Secure");
oChart.SeriesCollection[0].SetData(OWC11.ChartDimensionsEnum.chDimValues,
(int)OWC11.ChartSpecialDataSourcesEnum.chDataLiteral, SecureSeries);
oChart.SeriesCollection[0].DataLabelsCollection.Add();
oChart.SeriesCollection.Add(1);
oChart.SeriesCollection[1].SetData(OWC11.ChartDimensionsEnum.chDimSeriesName
s, (int)OWC11.ChartSpecialDataSourcesEnum.chDataLiteral, "Favorable");
oChart.SeriesCollection[1].SetData(OWC11.ChartDimensionsEnum.chDimValues,
(int)OWC11.ChartSpecialDataSourcesEnum.chDataLiteral, FavorableSeries);
oChart.SeriesCollection[1].DataLabelsCollection.Add();
oChart.SeriesCollection.Add(2);
oChart.SeriesCollection[2].SetData(OWC11.ChartDimensionsEnum.chDimSeriesName
s, (int)OWC11.ChartSpecialDataSourcesEnum.chDataLiteral, "Indifferent");
oChart.SeriesCollection[2].SetData(OWC11.ChartDimensionsEnum.chDimValues,
(int)OWC11.ChartSpecialDataSourcesEnum.chDataLiteral, IndifferentSeries);
oChart.SeriesCollection[2].DataLabelsCollection.Add();
oChart.SeriesCollection.Add(3);
oChart.SeriesCollection[3].SetData(OWC11.ChartDimensionsEnum.chDimSeriesName
s, (int)OWC11.ChartSpecialDataSourcesEnum.chDataLiteral, "At Risk");
oChart.SeriesCollection[3].SetData(OWC11.ChartDimensionsEnum.chDimValues,
(int)OWC11.ChartSpecialDataSourcesEnum.chDataLiteral, AtRiskSeries);
oChart.SeriesCollection[3].DataLabelsCollection.Add();
string VirtualFileName = "/srrs/charts/" +
System.DateTime.Now.Ticks.ToString() + ".gif";
string FullFileName = Server.MapPath(VirtualFileName);
oChartSpace.ExportPicture(FullFileName, "GIF", 400, 350);
Again, most of the time the chart works, but randomly I get a broken image
in I.E. because the chart object appearently wasn't written to disk. I do
know that the method is running because there is additional code in the
method that reports the chart data inside a table showing the values.
Ben