PDFsharp & MigraDoc Foundation

PDFsharp - A .NET library for processing PDF & MigraDoc Foundation - Creating documents on the fly
It is currently Mon Jul 01, 2024 10:14 am

All times are UTC


Forum rules


Please read this before posting on this forum: Forum Rules



Post new topic Reply to topic  [ 2 posts ] 
Author Message
PostPosted: Fri Mar 01, 2013 9:49 pm 
Offline

Joined: Fri Mar 01, 2013 9:17 pm
Posts: 4
I'm adding a chart to a MigraDoc Document:

Code:
            Chart chart = new Chart();
            chart.Left = 0;

            chart.Width = Unit.FromCentimeter(16);
            chart.Height = Unit.FromCentimeter(12);
            Series series = chart.SeriesCollection.AddSeries();
            series.ChartType = ChartType.Column2D;
            series.Add(0.13, 0.01, 0.49, 0.10, 0.57, 0.19);
            series.HasDataLabel = true;

            XSeries xseries = chart.XValues.AddXSeries();
            xseries.Add(/* some strings */);

            chart.XAxis.MajorTickMark = TickMarkType.Outside;
            chart.YAxis.MajorTickMark = TickMarkType.Outside;
            chart.YAxis.HasMajorGridlines = true;

            section.Add(chart);


I would like to have the data labels and y-axis labels on the chart formatted as percents. I attached a picture of what I want to see.

How do I:
1) Format the data labels as percents?
2) Format the y-axis labels as percents?
3) Move the data labels on top of the columns instead of inside of them?


Attachments:
chart_with_percents.png
chart_with_percents.png [ 14.15 KiB | Viewed 5453 times ]
Top
 Profile  
Reply with quote  
PostPosted: Mon Mar 04, 2013 8:23 pm 
Offline

Joined: Fri Mar 01, 2013 9:17 pm
Posts: 4
This code solved my problem:

Code:
series.DataLabel.Format = "#0.0%";
series.DataLabel.Position = DataLabelPosition.OutsideEnd;

//snip...

chart.YAxis.TickLabels.Format = "#0%";


I'm not sure, but it looked like the format of the Strings used for Format properties throughout MigraDoc follow the rules described here: http://msdn.microsoft.com/en-us/library/0c899ak8.aspx


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

All times are UTC


Who is online

Users browsing this forum: Bing [Bot] and 48 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:  
Privacy Policy, Data Protection Declaration, Impressum
Powered by phpBB® Forum Software © phpBB Group