I use DataManipulator.InsertEmptyPoints method to insert empty points in my chart series to align them and making stacked column graphs. I found in the follow simple example, if the data gap is too wide, i.e. too many empty points to insert, this method simply skip working without causing any exception.
The following code wont insert empty points, however it works fine if the gap is shortened (see inline comments). For testing, the code is a window form with a chart control called "Chart1".
Anybody know why?
Imports System.Windows.Forms.DataVisualization.Charting
Public Class Form1
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
Dim series1, series2 As New Series
series1.Points.AddXY(Date.Parse("1/1/2012"), 5) 'Try this with 1/1/2013 or 1/1/2014
series1.Points.AddXY(Date.Parse("1/1/2015"), 10)
series1.Points.AddXY(Date.Parse("2/1/2015"), 10)
series1.ChartType = SeriesChartType.Point
series1.Name = "A"
series2.Points.AddXY(Date.Parse("1/1/2015"), 20)
series2.Points.AddXY(Date.Parse("2/1/2015"), 20)
series2.Points.AddXY(Date.Parse("3/1/2015"), 20)
series2.ChartType = SeriesChartType.Point
series2.Name = "B"
Chart1.Series.Clear()
Chart1.Series.Add(series1)
Chart1.Series.Add(series2)
Chart1.DataManipulator.InsertEmptyPoints(1, IntervalType.Days, "A,B")
series1.EmptyPointStyle.MarkerColor = Color.Red
series2.EmptyPointStyle.MarkerColor = Color.Red
Chart1.ChartAreas(0).AxisX.Minimum = Date.Parse("1/12/2014").ToOADate
End Sub
End Class
Aucun commentaire:
Enregistrer un commentaire