I do apologise if this has been covered elsewhere but I cannot find an example that I can get working.
I have a simple graph to show the last 6 months of work of a company and the Y axis is fine showing the £ taken but the X axis I have labels 1 to 7 and cannot change them no matter what I do. I would like to explicitly set them to a month or maybe be able to pass in a variable?? I'm obviously missing something but wondered if anyone could point me in the right direction,
code is below:
Chart chart = new Chart(ChartType.Column2D); chart.Width = "25cm"; chart.Height = "15cm"; Series series = chart.SeriesCollection.AddSeries();
//XSeries xseries = chart.XValues.AddXSeries();
series.Add(new double[] { Convert.ToDouble(dgReports.Rows[0].Cells["Price0Month"].Value), Convert.ToDouble(dgReports.Rows[0].Cells["Price1Month"].Value), Convert.ToDouble(dgReports.Rows[0].Cells["Price2Month"].Value), Convert.ToDouble(dgReports.Rows[0].Cells["Price3Month"].Value), Convert.ToDouble(dgReports.Rows[0].Cells["Price4Month"].Value), Convert.ToDouble(dgReports.Rows[0].Cells["Price5Month"].Value), Convert.ToDouble(dgReports.Rows[0].Cells["Price6Month"].Value)});
series.HasDataLabel = true; series.DataLabel.CreateValue("Month1"); series.DataLabel.Type = DataLabelType.Value; series.DataLabel.Position = DataLabelPosition.OutsideEnd; //XSeries xseries = chart.XValues.AddXSeries(); /* XSeries xseries2 = chart.YAxis. Series series2 = chart.SeriesCollection.AddSeries(); series2.Add(new double[] { 0, 1, 2, 3 , 4, 5, 6}); */ series.FillFormat.Color = Colors.DarkGray; chart.XAxis.CreateValue("Month1"); chart.XAxis.TickLabels.CreateValue("Month1"); chart.XAxis.MajorTickMark = TickMarkType.Outside; chart.XAxis.Title.Caption = "Last 6 Months"; chart.HasDataLabel = true; chart.DataLabel.CreateValue("Month1"); chart.DataLabel.Type = DataLabelType.Value; chart.DataLabel.Position = DataLabelPosition.Center; chart.YAxis.MajorTickMark = TickMarkType.Outside; chart.YAxis.Title.Caption = "Account Work (£) "; chart.YAxis.Title.Orientation = 90; chart.YAxis.Title.Alignment = MigraDoc.DocumentObjectModel.Shapes.Charts.HorizontalAlignment.Center; chart.YAxis.TickLabels.Format = "#0£"; chart.YAxis.HasMajorGridlines = true; chart.PlotArea.LineFormat.Color = Colors.Black; chart.PlotArea.LineFormat.Width = 1; chart.PlotArea.LineFormat.Visible = true; document.LastSection.Add(chart);
|