I urgently need assistance. I am making a line chart with data markers. I have used the example that came with Aspose.Total to start, but there are a few things I cannot figure out.
1) I want the chart area to be bigger, but setting chart.ChartArea.Height = 20 and .Width = 20 don’t seem to be doing anything. How do I make the chart larger when the worksheet is created?
2) The X-Axis values are months, and right now it is generating and showing only every other month. I cannot seem to find an Interval property anywhere so that I can set it to 1. I made a new ChartArea object but it does not seem to include a definition for AxisX.Interval as shown in the code of one of the example files. How do I get the X-Axis values to show every month?
3) Right now the nseries names are not actually linked to the cells which contain the text for them. If the text in the cells is changed, the nseries names do not change. I want them to change on the chart if they are changed in the Excel sheet. How do I link the chart to the nseries title names the same way the cells with the month names are linked to for the X-Axis?
I have attached the Excel file that currently generates, and here is the code I am using to make the one chart in question:
private void CreateOSHACharts(Workbook workbook)
int chartIndex = 0;
chartIndex = workbook.Worksheets.Charts.Add(ChartType.LineWithDataMarkers, 16, 1, 28, 5);
Chart chart = workbook.Worksheets.Charts[chartIndex];
chart.MajorGridLines.IsVisible = true;
chart.PlotEmptyCellsType = PlotEmptyCellsType.NotPlotted;
//Set Properties of chart title
chart.Title.Text = “FY '” + selectedYearShort + " Incident Rates";
chart.Title.TextFont.Name = “Arial”;
chart.Title.TextFont.Color = Color.Black;
chart.Title.TextFont.IsBold = true;
chart.Title.TextFont.Size = 12;
//Set Properties of nseries
chart.NSeries.Add(workbook.Worksheets.Name + “!C18:F29”, true);
chart.NSeries.CategoryData = workbook.Worksheets.Name + “!B18:B29”;
chart.NSeries.IsColorVaried = true;
Cells cells = workbook.Worksheets.Cells;
for (int i = 0; i < chart.NSeries.Count; i++)
chart.NSeries[i].Name = cells[16, i+2].Value.ToString();
//Set the legend position type.
chart.Legend.Position = LegendPositionType.Bottom;
1)If you want to make the chart be bigger, please set Chart.ChartObject.Width and Chart.ChartObject.Height to adjust the chart's size.
2)Please use chart.CategoryAxis.TickLabelSpacing = 1 to set the number of catergories between tick-mark labels
3)Please use reference as the series name such ASeries.Name = "=Sheet1!A1";
It all worked. Thank you very much for your quick reply.