Hello,
I am having trouble with a DateTimeLine Chart with many Values.
In my values for this chart series I have for each day from Jan. 1. 2014 to May 31. 2014. But the chart render only one point for each month, and not for each day.
How can I setup the chart to show all the values?
Best regards.
Mikkel
DateTimeLineSeries Day values
Re: DateTimeLineSeries Day values
Support · Aug 6, 2014Hello,
The DynamicPDF Generator API displays all the X-axis labels by default. Please make sure you are setting the DateTimeType for the X-axis labels to Day. Please note that as the number of X-axis data points increases the chart may not have enough space to display the labels correctly. Also the width of the X-axis labels will be calculated based on the width of the chart, number of X-axis labels, X-axis minimum and X-axis maximum value. Sample code below uses fewer data points.
Document document = new Document();
Page page = new Page(PageSize.Letter, PageOrientation.Landscape);
document.Pages.Add(page);
DateTime startDate = new DateTime(2014, 01, 1);
Chart chartObj = new Chart(0, 0, 400, 150);
Title title = new Title("Chart 01", Font.Helvetica, 8) { Align = Align.Left };
chartObj.HeaderTitles.Add(title);
DateTimeXAxis xAxis = new DateTimeXAxis();
xAxis.Labels.Font = Font.Helvetica;
xAxis.Labels.FontSize = 6;
xAxis.DateTimeType = DateTimeType.Day;
xAxis.Interval = 1;
xAxis.MajorTickMarks = new XAxisTickMarks(30);
xAxis.MajorTickMarks.Width = 0.01f;
xAxis.MajorTickMarks.Visible = false;
xAxis.AxisPaddingInterval = 0;
xAxis.Max = new DateTime(2014, 1, 15);
xAxis.Min = new DateTime(2014, 1, 1);
DateTimeLineSeries lineSeries = new DateTimeLineSeries("Var", xAxis, new NumericYAxis());
DateTime dtTime = startDate;
for (int i = 0; i < 15; i++)
{
DateTimeLineValue newValue = new DateTimeLineValue((i * 1500) / 1000, dtTime.Date); ;
dtTime = dtTime.AddDays(1);
lineSeries.Values.Add(newValue);
}
lineSeries.XAxis.LabelFormat = "MMM:dd";
chartObj.PrimaryPlotArea.Series.Add(lineSeries);
lineSeries.Legend.Visible = false;
lineSeries.YAxis.LabelFormat = "#,##0";
lineSeries.YAxis.Labels.FontSize = 8;
lineSeries.YAxis.Labels.Font = Font.Helvetica;
lineSeries.YAxis.MajorGridLines = new YAxisGridLines();
lineSeries.YAxis.MajorGridLines.Visible = true;
lineSeries.YAxis.MajorGridLines.Width = 0.5f;
lineSeries.YAxis.MajorGridLines.Color = RgbColor.LightGrey;
chartObj.Legends.Placement = LegendPlacement.BottomCenter;
chartObj.Legends.LabelsLayout = LayOut.Horizontal;
page.Elements.Add(chartObj);
document.Draw(@"C:\Temp\LineChart.pdf");
Thanks,
ceTe Software Support Team.