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 [ 13.09 KiB | Viewed 7594 times ]
Thank you for the help