PDFsharp & MigraDoc Foundation

PDFsharp - A .NET library for processing PDF & MigraDoc Foundation - Creating documents on the fly
It is currently Fri Mar 29, 2024 11:39 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: Tue Jan 27, 2015 5:42 pm 
Offline

Joined: Fri Nov 14, 2014 1:14 am
Posts: 4
Hi, How do you set chart's x-axis label's viable to false or make don't show at all.
I am using C# and only use migradoc.

My Code
Code:
#region Bar Chart
            chart = new Chart(ChartType.Bar2D);
            chart.Format.KeepTogether = true;
            chart.Left = 0;

            chart.Width = Unit.FromCentimeter(16.3);
            chart.Height = Unit.FromCentimeter(8);
            series = chart.SeriesCollection.AddSeries();
            List<double> ChartValuesList = new List<double>();
            for (int i = 0; i < ChartDataList.Count(); i++)
            {
                if (ChartDataList[i].FName.Equals("Something"))
                {
                    ChartValuesList .Add((double)Math.Round((double)ChartDataList[i].Score / ChartDataList[i].MaxScoure, 2));
                }
            }

            series.Add(ChartValuesList .ToArray());
            //series.HasDataLabel = true;
            //series.DataLabel.Format = "#0.0%";

            elements = series.Elements.Cast<MigraDoc.DocumentObjectModel.Shapes.Charts.Point>().ToArray();
            for (int i = 0; i < ChartValuesList.Count(); i++)
            {
                if (ChartValuesList[i] <= 0.35f)
                {
                    elements[i].FillFormat.Color = Colors.Chartreuse;
                }
                else if (ChartValuesList[i] <= 0.70f)
                {
                    elements[i].FillFormat.Color = Colors.Orange;
                }
                else
                {
                    elements[i].FillFormat.Color = Colors.Red;
                }

            }

            xseries = chart.XValues.AddXSeries();
            xseries.Add(.........);

            chart.XAxis.MajorTickMark = TickMarkType.Outside;
            //chart.XAxis.Title.Caption = "X-Axis";

            chart.YAxis.MajorTickMark = TickMarkType.Outside;
            chart.YAxis.MaximumScale = 1.001f;
            chart.YAxis.HasMajorGridlines = true;
            chart.YAxis.TickLabels.Format = "#0%";

            chart.PlotArea.LineFormat.Color = Colors.DarkGray;
            chart.PlotArea.LineFormat.Width = 1;

            table = document.LastSection.AddTable();
            table.KeepTogether = true;
            //table.Borders.Width = 0.3f;

            column = table.AddColumn("17.4cm");
            row = table.AddRow();
            row.KeepWith = 1;
            row.Cells[0].Add(chart);

            row = table.AddRow();
            row.Cells[0].AddParagraph("Assessment Chart");
            row.Cells[0].Format.Alignment = ParagraphAlignment.Center;
            row.Cells[0].Format.Font.Bold = true;
            row.Cells[0].Format.Font.Size = 16;
            row.Cells[0].Format.SpaceAfter = 5;

            #endregion



I did find a way to do it, but is stupid. I hope there is a better way to do this.

Code:
            chart.YAxis.MajorTickMark = TickMarkType.Inside;
            chart.YAxis.MaximumScale = 1.001f;
            chart.YAxis.HasMajorGridlines = true;
            chart.YAxis.TickLabels.Format = "#0%";
            chart.YAxis.TickLabels.Font.Size = 0.01f;
            chart.YAxis.TickLabels.Font.Color = Colors.White;


This is what I want to achieve, but without the huge gap between Font: "Less", "More" and the chart
currently I am using table to add less and more, but the table thinks the x-axis values still there. That why there is a huge gap
Attachment:
File comment: chart Image
support1.PNG
support1.PNG [ 13.09 KiB | Viewed 6303 times ]



Thank you for the help


Top
 Profile  
Reply with quote  
PostPosted: Mon Apr 25, 2016 3:58 pm 
Offline

Joined: Sun Apr 24, 2016 6:43 pm
Posts: 3
Did you solve the issue?


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: No registered users and 156 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