Unavailable Chart Type


#1

In your programmers guide of Wiki for Excel, under Creating Charts, the sub category Chart Types shows a screen print for the Chart Type "stock", but the table containing the Type Code and Description beneath it are empty.

How do I create this type of chart?


#2

Stock charts is not fully supported yet. Please try this attached version, it supports StockHighLowClose chart type.

Excel excel = new Excel();

Cells cells = excel.Worksheets[0].Cells;
cells["a1"].PutValue(1);
cells["a2"].PutValue(2);
cells["a3"].PutValue(3);

cells["b1"].PutValue(4);
cells["b2"].PutValue(5);
cells["b3"].PutValue(6);


cells["C1"].PutValue(7);
cells["C2"].PutValue(8);
cells["C3"].PutValue(9);


int chartIndex = excel.Worksheets[0].Charts.Add(ChartType.StockHighLowClose, 11, 0, 27, 13);

Chart chart = excel.Worksheets[0].Charts[chartIndex];
chart.NSeries.Add("A1:c3", true);

excel.Save("c:\\stockchart.xls");

Please let me know if you need to create other stock charts.


#3

Thanks for the quick fix.

However, It's not drawing correctly. I have attached a document with what I'm getting and what I'm trying to get.


#4

More code is needed to create such a chart. Could you please post your manually created Excel file with your desire chart here? It can help us to exactly know your need. Thank you very much.


#5

I have attached the file that was sent to me by our client.

Thanks!


#6

Please try this attached fix with the following sample code:

Excel excel = new Excel();

excel.Open("d:\\test\\prisa control chart.xls");

excel.Worksheets.Add(SheetType.Chart);

int chartIndex = excel.Worksheets[4].Charts.Add(ChartType.StockHighLowClose, 0, 0, 0, 0);

Chart chart = excel.Worksheets[4].Charts[chartIndex];
chart.NSeries.Add("'Data Table'!B7:N7", false);
chart.NSeries.Add("'Data Table'!B6:N6", false);
chart.NSeries.Add("'Data Table'!B8:N8", false);

chart.PlotArea.Area.ForegroundColor = Color.Silver;

chart.NSeries.CategoryData = "'Data Table'!B4:N4";
chart.CategoryAxis.CategoryType = CategoryType.CategoryScale;
chart.CategoryAxis.AxisBetweenCategories = false;
chart.CategoryAxis.AxisLine.Style = LineType.Dash;
chart.CategoryAxis.AxisLine.Weight = WeightType.MediumLine;

chart.ValueAxis.MajorUnit = 0.25;
chart.ValueAxis.MinorUnit = 0.05;

chart.MajorGridLines.Style = LineType.Dot;

chart.Title.Text = "Prisa 945 Waist";
chart.Title.TextFont.IsBold = true;
chart.Title.TextFont.Size = 12;
chart.Legend.Position = LegendPositionType.Top;

chart.NSeries[0].Line.IsVisible = true;
chart.NSeries[0].Line.Color = Color.Blue;
chart.NSeries[0].Line.Weight = WeightType.MediumLine;
chart.NSeries[0].MarkerStyle = ChartMarkerType.None;
chart.NSeries[0].Smooth = true;
chart.NSeries[0].Name = "='Data Table'!A7";

chart.NSeries[1].Line.IsVisible = true;
chart.NSeries[1].Line.Color = Color.Red;
chart.NSeries[1].Line.Weight = WeightType.MediumLine;
chart.NSeries[1].MarkerStyle = ChartMarkerType.None;
chart.NSeries[1].Smooth = true;
chart.NSeries[1].Name = "='Data Table'!A6";

chart.NSeries[2].Line.IsVisible = true;
chart.NSeries[2].Line.Color = Color.Blue;
chart.NSeries[2].Line.Weight = WeightType.MediumLine;
chart.NSeries[2].MarkerStyle = ChartMarkerType.None;
chart.NSeries[2].Smooth = true;
chart.NSeries[2].Name = "='Data Table'!A8";

excel.Worksheets[4].Zoom = 75;

Could you please tell me how you created the UCL and LCL line? I don't find them in Excel chart setting.


#7

This works nicely!

I'll talk with our client and see how the created the UCL and LCL lines and I'll get back to you.

Thanks again for the responsiveness!