By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,678 Members | 2,192 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,678 IT Pros & Developers. It's quick & easy.

OWC 11: Is it possible to have combination chart?

P: 6
I am using OWC 11 in my new web application for displaying charts.
Is it possible in OWC 11 to combine and display a column and a line graph (Looking like they overlap each other)?
I tried it using this code but it doesn' t work.

Expand|Select|Wrap|Line Numbers
  1.  
  2. int width = 400;
  3. int height = 300;
  4.  
  5. Bitmap bmpChart = new Bitmap(width, height, PixelFormat.Format16bppRgb555);
  6.  
  7. OWC11.ChartSpace chSpace = new ChartSpaceClass();
  8.  
  9. ChChart chart = chSpace.Charts.Add(0);
  10. chart.SeriesCollection.Add(0);
  11. chart.SeriesCollection[0].Type = ChartChartTypeEnum.chChartTypeColumn3D;
  12.  
  13. // Series names
  14. chart.SeriesCollection[0].SetData(ChartDimensionsEnum.chDimSeriesNames, Convert.ToInt32(ChartSpecialDataSourcesEnum.chDataLiteral), "test");
  15.  
  16. chart.SeriesCollection[0].SetData(ChartDimensionsEnum.chDimCategories, Convert.ToInt32(ChartSpecialDataSourcesEnum.chDataLiteral), "a,b,c");
  17.  
  18. chart.SeriesCollection[0].SetData(ChartDimensionsEnum.chDimValues, Convert.ToInt32(ChartSpecialDataSourcesEnum.chDataLiteral), "5,10,15"); 
  19.  
  20.  
  21. chart.SeriesCollection.Add(1); // series collection xbar
  22.  
  23. chart.SeriesCollection[1].Type = ChartChartTypeEnum.chChartTypeLine;
  24.  
  25. chart.SeriesCollection[1].Marker.Size = 6; // marker size
  26. chart.SeriesCollection[1].Interior.Color = "Red"; // marker color
  27.  
  28. chart.SeriesCollection[1].Marker.Style = ChartMarkerStyleEnum.chMarkerStyleCircle; // marker style
  29.  
  30. chart.SeriesCollection[1].Line.Color = "Red";
  31.  
  32. // Set line weight.
  33. chart.SeriesCollection[1].Line.set_Weight((LineWeightEnum)int.Parse("3"));
  34.  
  35. // Series names
  36. chart.SeriesCollection[1].SetData(ChartDimensionsEnum.chDimSeriesNames, Convert.ToInt32(ChartSpecialDataSourcesEnum.chDataLiteral), "test");
  37.  
  38. chart.SeriesCollection[1].SetData(ChartDimensionsEnum.chDimCategories, Convert.ToInt32(ChartSpecialDataSourcesEnum.chDataLiteral), "a,b,c");
  39.  
  40. chart.SeriesCollection[1].SetData(ChartDimensionsEnum.chDimValues, Convert.ToInt32(ChartSpecialDataSourcesEnum.chDataLiteral), "20,25,30");
  41.  
  42. chart.HasLegend = true;
  43. chart.Legend.Position = ChartLegendPositionEnum.chLegendPositionRight;
  44. chart.Axes[0].Orientation = Convert.ToInt32(OWC11.ChartLabelOrientationEnum.chLabelOrientationHorizontal);
  45.  
  46. return chSpace;
  47.  
If you have any solution, please reply to this thread. Thanks in advance.
Feb 24 '09 #1
Share this Question
Share on Google+
1 Reply


P: 6
I managed to solve this myself. I just translated a VB example from Microsoft.

Expand|Select|Wrap|Line Numbers
  1. {
  2.             int width = 400;
  3.             int height = 300;
  4.  
  5.             Bitmap bmpChart = new Bitmap(width, height, PixelFormat.Format16bppRgb555);
  6.  
  7.             OWC11.ChartSpace chSpace = new ChartSpaceClass();
  8.  
  9.             chSpace.Clear();
  10.  
  11.             ChChart chart = chSpace.Charts.Add(0);
  12.  
  13.             OWC11.ChSeries series1 = chart.SeriesCollection.Add(0);
  14.             //series1.Caption = "sales";
  15.             series1.SetData(ChartDimensionsEnum.chDimCategories, Convert.ToInt32(ChartSpecialDataSourcesEnum.chDataLiteral), "5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24");
  16.             series1.SetData(ChartDimensionsEnum.chDimValues, Convert.ToInt32(ChartSpecialDataSourcesEnum.chDataLiteral), "0, 0, 0, 4, 268, 44, 10, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0"); 
  17.             series1.Interior.Color = "#CCFFFF";
  18.             series1.GapWidth = 0;
  19.             series1.Type = ChartChartTypeEnum.chChartTypeColumnClustered;
  20.  
  21.             series1.DataLabelsCollection.Add();
  22.                series1.DataLabelsCollection[0].Font.Name = "Arial";
  23.             series1.DataLabelsCollection[0].Font.Size = 9;
  24.             //series1.DataLabelsCollection[0].Font.Bold = true;
  25.  
  26.             OWC11.ChSeries series2 = chart.SeriesCollection.Add(1);
  27.             //series2.Caption = "profit";
  28.             series2.SetData(ChartDimensionsEnum.chDimCategories, Convert.ToInt32(ChartSpecialDataSourcesEnum.chDataLiteral), "5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24");
  29.             series2.SetData(ChartDimensionsEnum.chDimValues, Convert.ToInt32(ChartSpecialDataSourcesEnum.chDataLiteral), "0, 9.85, 0.001, 2.43, 112.52, 195.80, 15.22, 0.03, 1.18, 7.4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0"); 
  30.             series2.Line.Color = "Black";
  31.             series2.Type = ChartChartTypeEnum.chChartTypeSmoothLine;
  32.  
  33.             chart.Axes[1].Scaling.Minimum = 0;
  34.             //chart.Axes[1].Scaling.Maximum = 320;
  35.  
  36.             chart.Interior.SetSolid("#CCFFFF");
  37.  
  38.             chart.PlotArea.Interior.SetPatterned(ChartPatternTypeEnum.chPattern90Percent, "White", "Black");
  39.             chart.Axes[1].HasMajorGridlines = false;//  Line.set_Weight((LineWeightEnum.owcLineWeightHairline)); // Y-Axis line color
  40.  
  41.             chart.Border.Color = "Black";
  42.  
  43.             return chSpace;
  44.         }
  45.  
Feb 27 '09 #2

Post your reply

Sign in to post your reply or Sign up for a free account.