Group: Forum Members
Last Active: 2 Years Ago
Posts: 11,
Visits: 67
|
Hi, In my smooth-line plot, the x-values are dates and the y-values are percentages. The issue is that I have monthly values at the beginning section of my plot, however, after two years, the dates are updated on yearly basis, therefore the dates do not have consistent intervals. Please find attached the plot I've created using the Microsoft chart control. I would like to use Nevron to reproduce this plot but unfortunately it treats the dates as categories and not datetime variables. Thanks a lot for your help
|
Group: Forum Members
Last Active: Yesterday @ 1:38 AM
Posts: 3,054,
Visits: 4,006
|
Hello Vahid, This is caused by the default axis scaling. You can use the following custom C# code: using System; using System.Drawing; using Nevron.GraphicsCore; using Nevron.Chart; using Nevron.ReportingServices;
namespace MyNamespace { /// <summary> /// Sample class /// </summary> public class MyClass { /// <summary> /// Main entry point /// </summary> /// <param name="context"></param> public static void RSMain(NRSChartCodeContext context) { NChart chart = context.document.Charts[0]; NDateTimeScaleConfigurator dateTimeScale = chart.Axis(StandardAxis.PrimaryX).ScaleConfigurator as NDateTimeScaleConfigurator;
if (dateTimeScale != null) { bool hasMin = false; DateTime minValue = new DateTime(); foreach (NSeriesBase series in chart.Series) { NXYScatterSeries xyScatter = series as NXYScatterSeries;
if (xyScatter != null && xyScatter.XValues.Count > 0) { DateTime curXValue = DateTime.FromOADate((double)xyScatter.XValues[0]); if (hasMin) { minValue = minValue < curXValue ? minValue : curXValue; } else { hasMin = true; minValue = curXValue; } } }
if (hasMin) { dateTimeScale.UseOrigin = true;
dateTimeScale.Origin = new DateTime(minValue.Year, minValue.Month, 1, 0, 0, 0); } } } } }
Best Regards, Nevron Support Team
|