65.9K
CodeProject is changing. Read more.
Home

Simple Charts Using OWC (Office Web Component)

starIconstarIconstarIcon
emptyStarIcon
starIcon
emptyStarIcon

3.94/5 (9 votes)

Feb 1, 2006

viewsIcon

122618

downloadIcon

3601

An article on Simple Chart Representation Using OWC

Sample Image

Introduction

This is a simple project for beginners to get some knowledge about using OWC in a C#.NET application for chart representation.

Background

Office 2003 Web Components do not provide event handling by default. We need to do some alterations. Kindly follow this link to get more information: Handle Events for the Office 2003 Web Components in Visual Studio .NET.

Using the code

After we convert OWC for event handling, we can add a reference to our project.

Steps

  1. Create a OWC Chart.
  2. Add the required number of chart series in it.
  3. Give the values for each chart series.
  4. Customize your chart to display it in the format you wish.
string strSeriesName = "My Series";
string strCategory = "1,2,3,4,5";
string strValue = "3,8,2,8,4";
//Add a series to the chart’s series collection
ChSeries series = chchart.SeriesCollection.Add(0);
//Give the name of the series
chchart.SeriesCollection[0].SetData(
  OWC10.ChartDimensionsEnum.chDimSeriesNames, 
  (int)OWC10.ChartSpecialDataSourcesEnum.chDataLiteral, 
  strSeriesName);
//Give the Categories
chchart.SeriesCollection[0].SetData(
  OWC10.ChartDimensionsEnum.chDimCategories, 
  (int)OWC10.ChartSpecialDataSourcesEnum.chDataLiteral, 
  strCategory);
//Give The values
chchart.SeriesCollection[0].SetData(
  OWC10.ChartDimensionsEnum.chDimValues, 
  (int)OWC10.ChartSpecialDataSourcesEnum.chDataLiteral, 
  strValue); 
series.Line.set_Weight(
  OWC10.LineWeightEnum.owcLineWeightHairline);

Points of Interest

I hope you've enjoyed this little tutorial. In future, I will provide you lot more stuff. And I am expecting your valuable suggestions.