Hello,
I am creating a chart using the example given in (DefineCharts is called by CreateDocument):
http://www.pdfsharp.net/wiki/HelloMigraDoc-sample.ashxHowever the x-axis in this example are strings, and my data is of type double. I converted the a double array to string array and added it to XSeries of the chart.
The problem is that the x-ticks are displayed for every value in the XSeries, I want to set the x-ticks to something like 2.0 or 10.0, setting a value to chart.XAxis.MajorTick does not have any effect.
Can anyone tell me how to set the Major ticks so that the values on x-axis are readable ?
What I expect to see is values for x which are spaced evenly in steps like 45, 55, 65, 75...... Currently all the values in values_X here displayed along the x-axis.
See the code example:
Code:
// Input data: values_Y and values_X are double arrays
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.Line;
series.Add(values_Y);
XSeries xseries = chart.XValues.AddXSeries();
foreach (var value in values_X)
{
xseries.Add(value.ToString());
}
chart.XAxis.MajorTick = 10.0; // Setting the MajorTick here which does not have any effect !
chart.XAxis.MajorTickMark = TickMarkType.Outside;
chart.XAxis.Title.Caption = "X-Axis";
chart.YAxis.MajorTick = 10.0;
chart.YAxis.MajorTickMark = TickMarkType.Outside;
chart.YAxis.HasMajorGridlines = true;
chart.PlotArea.LineFormat.Color = Colors.DarkGray;
chart.PlotArea.LineFormat.Width = 1;
document.LastSection.Add(chart);
By the way the x values do not start from 0.