private Axis ConvertAxis(ChartAxisViewModel axis) { Axis newAxis = null; switch (axis.AxisType) { case (ChartAxisType.CategoryX): { newAxis = new CategoryAxis { LabelField = axis.ValueMemberPath, ItemsSource = axis.DataSource.Data }; break; } case (ChartAxisType.NumericX): case (ChartAxisType.NumericY): { newAxis = new LinearAxis { }; break; } case(ChartAxisType.CategoryDateTimeX): { var dtaxis = new DateTimeAxis { IntervalType = DateTimeIntervalType.Auto, }; var scale = axis.GetScaleForProperty(axis.ValueMemberPath); if (null != scale) { scale.PropertyChanged += (s, a) => { if( a.PropertyName != "Minimum" && a.PropertyName != "Maximum") { return; } var min = new DateTime((long)scale.Minimum); var max = new DateTime((long)scale.Maximum); var laxis = _plotModel.Axes.FirstOrDefault(x => x.Title == scale.Name) as DateTimeAxis; if( null == laxis ) { return; } var delta = max - min; var lmax = 0.0d; var lmin = 0.0d; if (TimeSpan.FromSeconds(1) > delta) { laxis.IntervalType = DateTimeIntervalType.Seconds; } else if (TimeSpan.FromMinutes(1) > delta) { laxis.IntervalType = DateTimeIntervalType.Minutes; } else if (TimeSpan.FromHours(1) > delta) { laxis.IntervalType = DateTimeIntervalType.Hours; } else if (TimeSpan.FromDays(1) > delta) { laxis.IntervalType = DateTimeIntervalType.Days; } else if (TimeSpan.FromDays(30) > delta) { laxis.IntervalType = DateTimeIntervalType.Months; } else { laxis.IntervalType = DateTimeIntervalType.Auto; } //TODO: remove laxis.IntervalType = DateTimeIntervalType.Seconds; //laxis.Minimum = scale.Minimum; //laxis.Maximum = scale.Maximum; OnPlotModelChanged(); }; } newAxis = dtaxis; break; } } if (null == newAxis) { return null; } switch (axis.AxisLocation) { case(AxisLocation.InsideBottom): case(AxisLocation.OutsideBottom): { newAxis.Position = AxisPosition.Bottom; break; } case (AxisLocation.InsideTop): case (AxisLocation.OutsideTop): { newAxis.Position = AxisPosition.Top; break; } case (AxisLocation.InsideLeft): case (AxisLocation.OutsideLeft): { newAxis.Position = AxisPosition.Left; break; } case (AxisLocation.InsideRight): case (AxisLocation.OutsideRight): { newAxis.Position = AxisPosition.Right; break; } default: { newAxis.Position = AxisPosition.None; break; } } newAxis.Title = axis.Name; var series = axis.AxisScaleDescriptors.FirstOrDefault(); if (null != series) { newAxis.Title = series.Scale.Name; } newAxis.Key = newAxis.Title; return newAxis; }