共用方式為


對齊資料 (Chart 控制項)

如果兩個數列具有相同數目的資料點且其對應 X 值具有相同資料,它們就會視為對齊。

對齊資料

使用下列其中一種方法或組合來對齊資料。

  • 篩選
    從每個數列移除不需要的資料點,讓所有數列都有相同數目的資料點。如需詳細資訊,請參閱篩選資料

  • 群組
    依必要間隔來群組數列中的資料點,例如天數、週數和月數。如需詳細資訊,請參閱群組資料

  • 插入空點
    空點表示遺失之資料,可用來在所有數列中維護一致數目的資料點。如需詳細資訊,請參閱使用空資料點

下列程式碼示範如何透過群組資料、加入空點,然後篩選資料,對齊兩個數列。它會對齊 Series1 和 Series2,這兩個數列每天可能沒有資料點或每天可能有多個資料點。

' Group all sales for each day into one point, with the Y value set to the total sales.
Chart1.DataManipulator.Group("SUM", 1, IntervalType.Days, "Series1, Series2")

' Insert empty points for each day if no data point exists.
Chart1.DataManipulator.InsertEmptyPoints(1, IntervalType.Days, "Series1, Series2")

' Remove Sundays and Saturdays from the series.
Chart1.DataManipulator.Filter(DateRangeType.DayOfWeek, "0,6", "Series1, Series2")
// Group all sales for each day into one point, with the Y value set to the total sales.
Chart1.DataManipulator.Group("SUM", 1, IntervalType.Days, "Series1, Series2");

// Insert empty points for each day if no data point exists.
Chart1.DataManipulator.InsertEmptyPoints(1, IntervalType.Days, "Series1, Series2");

// Remove Sundays and Saturdays from the series.
Chart1.DataManipulator.Filter(DateRangeType.DayOfWeek, "0,6", "Series1, Series2");

請參閱

參考

System.Windows.Forms.DataVisualization.Charting

System.Web.UI.DataVisualization.Charting

其他資源

資料繫結和操作