Академический Документы
Профессиональный Документы
Культура Документы
Page 1 of 3
Target readers: Developers working on any Web Application project to generate Charts.
//X-axis Values
string strDates = @"3/21/2009\t3/22/2009\t3/23/2009\t3/24/2009\t3/25/2009\t3/26/2009\t";
//Y-axis Values
string strValues1 = @"4\t0\t7\t0\t0\t5\t";
string strValues2 = @"3\t0\t8\t0\t0\t5\t";
//Generate Chart
space = Graphics.BuildChart(strDates, strValues1, strValues2, strChartTitle);
Public static OWC10.ChartSpaceClass BuildChart BuildChart(string strCategories, string strValues1, string strValues2, s
{
OWC10.ChartSpaceClass space = new OWC10.ChartSpaceClass();
3
space.Charts.Add(0);
3
http://www.dotnetspider.com/resources/35679-Generating-Charts-Using-Microsoft-O... 01-03-2011
Generating Charts Using Microsoft Office XP Web Components Samples and exampl... Page 2 of 3
space.Charts[0].Type = OWC10.ChartChartTypeEnum.chChartTypeColumnStacked;
3
//For this graph we have X and Y axis, to Show 2 series on Y axisadd 2 series to series Collection one for ‘
space.Charts[0].SeriesCollection.Add(0);
space.Charts[0].SeriesCollection[0].DataLabelsCollection.Add();
space.Charts[0].SeriesCollection.Add(1);
3
If you're charting a pie or a variation thereof percentages make a lot more sense than values.
//In this case we are using Column stacked so set Has Value to true
space.Charts[0].SeriesCollection[0].DataLabelsCollection[0].HasPercentage = false;
space.Charts[0].SeriesCollection[0].DataLabelsCollection[0].HasValue = true;
3
http://www.dotnetspider.com/resources/35679-Generating-Charts-Using-Microsoft-O... 01-03-2011
Generating Charts Using Microsoft Office XP Web Components Samples and exampl... Page 3 of 3
Now set the data for Sent series on Y-axis and data on X-axis
//Set Data the Sent Series on Y Axis and Data for Dates on X-axis
space.Charts[0].SeriesCollection[0].SetData(OWC10.ChartDimensionsEnum.chDimCategories,
Convert.ToInt32(OWC10.ChartSpecialDataSourcesEnum.chDataLiteral), chartCategoriesStr);
space.Charts[0].SeriesCollection[0].SetData(OWC10.ChartDimensionsEnum.chDimValues,
Convert.ToInt32(OWC10.ChartSpecialDataSourcesEnum.chDataLiteral), chartValuesStr1);
3
Set the data for Failed Series on Y-Axis and data on X-axis
//Set Data the Failed Series on Y Axis and Data for Dates on X-axis
space.Charts[0].SeriesCollection[1].SetData(OWC10.ChartDimensionsEnum.chDimCategories,
Convert.ToInt32(OWC10.ChartSpecialDataSourcesEnum.chDataLiteral), chartCategoriesStr);
space.Charts[0].SeriesCollection[1].SetData(OWC10.ChartDimensionsEnum.chDimValues,
Convert.ToInt32(OWC10.ChartSpecialDataSourcesEnum.chDataLiteral), chartValuesStr2);
//Now return the object and generate gif or jpg image to display on client side
return space;
}
3
Conclusion
Microsoft office XP Web Components saves the developer’s time and effort by providing simple approach to generate Charts. With this example shown in the above sections, the reader would be com
Web Components DLL. By using this document, a developer can be able to generate complex charts depending up on their requirement.
http://www.dotnetspider.com/resources/35679-Generating-Charts-Using-Microsoft-O... 01-03-2011