This question is locked. New answers and comments are not allowed.
Hi,
I have a line chart for which I'm trying to implement scrolling and zooming. The X-Axis shows dates, so maybe that's the problem. Anyway, zooming and scrolling work fine on the Y-Axis, but have no effect on the X-Axis.
Here's my code. It's all done in codebehind. Thanks in advance.
Aaron
I have a line chart for which I'm trying to implement scrolling and zooming. The X-Axis shows dates, so maybe that's the problem. Anyway, zooming and scrolling work fine on the Y-Axis, but have no effect on the X-Axis.
Here's my code. It's all done in codebehind. Thanks in advance.
Aaron
void renderChart(ObservableCollection<WeeklyTemp> temps){ RadChart radChart1 = new RadChart(); radChart1.DefaultView.ChartTitle.Content = "MWAT Garcia River Forest 2008"; radChart1.DefaultView.ChartTitle.HorizontalAlignment = HorizontalAlignment.Center; radChart1.DefaultView.ChartLegend.UseAutoGeneratedItems = true; radChart1.DefaultView.ChartLegend.Width = 200; radChart1.DefaultView.ChartLegend.Margin = new Thickness(40, 0, 0, 0); radChart1.DefaultView.ChartArea.AxisX.LabelRotationAngle = 300; radChart1.DefaultView.ChartArea.AxisX.IsDateTime = true; radChart1.DefaultView.ChartArea.AxisX.DefaultLabelFormat = "d"; radChart1.DefaultView.ChartArea.AxisX.Title = "Date"; radChart1.DefaultView.ChartArea.AxisY.Title = "Tempurature (C)"; radChart1.DefaultView.ChartArea.AxisX.MajorGridLinesVisibility = Visibility.Visible; radChart1.DefaultView.ChartArea.AxisY.MajorGridLinesVisibility = Visibility.Visible; radChart1.DefaultView.ChartArea.ZoomScrollSettingsX.ScrollMode = ScrollMode.ScrollAndZoom; radChart1.DefaultView.ChartArea.ZoomScrollSettingsY.ScrollMode = ScrollMode.ScrollAndZoom; TimeSpan ts = endDate.Subtract(startDate);
int days = ts.Days; int period = days / 10; radChart1.DefaultView.ChartArea.AxisX.AddRange(startDate.ToOADate(), endDate.ToOADate(), period); radChart1.DefaultView.ChartArea.DataSeries.Clear(); IEnumerable<GarciaSite> selectedSites = from s in sites where s.isSelected == true select s; foreach (GarciaSite site in selectedSites) { DataSeries lineSeries = new DataSeries(); lineSeries.LegendLabel = site.siteName; LineSeriesDefinition def = new LineSeriesDefinition(); string siteColor = site.color.Replace("#", "#FF"); SolidColorBrush theBrush = GetColorFromHexa(siteColor); def.Appearance.Stroke = theBrush; def.ShowItemLabels = false; def.ShowPointMarks = false; lineSeries.Definition = def; // add data to the series var data = from m in temps where m.siteID.Equals(site.siteID) select new { m.date, m.movAvg }; foreach (var d in data) { DataPoint dp = new DataPoint(d.date.ToOADate(), d.movAvg); lineSeries.Add(dp); } radChart1.DefaultView.ChartArea.DataSeries.Add(lineSeries); } spChart.Children.Clear(); spChart.Children.Add(radChart1);}