PDFsharp & MigraDoc Foundation

PDFsharp - A .NET library for processing PDF & MigraDoc Foundation - Creating documents on the fly
It is currently Fri Jun 23, 2017 1:41 pm

All times are UTC


Forum rules


Please read this before posting on this forum: Forum Rules



Post new topic Reply to topic  [ 1 post ] 
Author Message
PostPosted: Wed Sep 14, 2016 3:01 pm 
Offline

Joined: Tue Mar 04, 2014 9:56 am
Posts: 9
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);


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 1 post ] 

All times are UTC


Who is online

Users browsing this forum: Baidu [Spider], Bing [Bot] and 11 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group