Hello,
So far, so good, I can create a chart using migradoc:
Code:
private Chart CreatePdfChart(IEnumerable<IDictionary<string, object>> topHundred)
{
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.MarkerStyle = MarkerStyle.None;
series.LineFormat.Color = Colors.Red;
XSeries xseries = chart.XValues.AddXSeries();
int i = 0;
foreach (var point in topHundred)
{
var value = point["Value"].ToString().Trim();
CultureInfo ci = CultureInfo.InvariantCulture;
var b = double.TryParse(value, NumberStyles.AllowDecimalPoint, ci, out var d);
if (b)
{
series.Add(d);
}
else
{
series.Add(0);
}
var date = (DateTime.Parse(point["Date"].ToString())).ToString("d/M/yyyy H:m:s");
if (i%10==0)
{
xseries.Add(date);
}
else
{
xseries.AddBlank();
}
i++;
}
chart.XAxis.MajorTickMark = TickMarkType.Outside;
chart.XAxis.Title.Caption = "Time";
chart.YAxis.MajorTickMark = TickMarkType.Outside;
chart.YAxis.HasMajorGridlines = true;
chart.PlotArea.LineFormat.Color = Colors.Black;
chart.PlotArea.LineFormat.Width = 1;
return chart;
}
It works lovely.
However a question, is it possible to rotate clockwise by 90° XSerie labels? I looked at many sites or forum and I didn't find any answer.
Thanks in advance for your help,
Kind regards,