RangeBarグラフ領域(System.Windows.Forms.DataVisualization.Charting)にデータをプロットしようとしていますが、縦軸にラベルのテキスト値があるときにデータをグループ化する際に問題が発生しています。MSChart:RangeBarデータをインデックスの代わりにテキストラベルでグループ化するにはどうすればよいですか?
ここ関連コードは次のとおり
var connectedTimeRangeSeries = theChart.Series.Add("ConnectedTimeRangeSeries");
var connectedTimeRangesChartArea = theChart.ChartAreas["PerItemConnectedChartArea"];
connectedTimeRangeSeries.ChartArea = connectedTimeRangesChartArea.Name;
connectedTimeRangeSeries.ChartType = SeriesChartType.RangeBar;
connectedTimeRangeSeries.XValueType = ChartValueType.Auto;
connectedTimeRangeSeries.YValueType = ChartValueType.Auto;
for (int i = 0; i < timeRanges.Count; i++)
{
string theLabel = timeRanges[i].ItemLabel;
connectedTimeRangeSeries.Points.AddXY(timeRanges[i].ItemId + 1, timeRanges[i].StartConnectionTime, timeRanges[i].StopConnectionTime);
}
timeRanges
は、これらの部材の種類(大文字の名前を対応するパブリックプロパティを介してアクセス)を有するアイテムを含むリストである:
private int itemId;
private string itemLabel;
private DateTime startConnectionTime;
private DateTime stopConnectionTime;
私はDataSeries.Points.AddXY()
を呼び出すとX型を整数として返します(Xは範囲バーの縦軸です)。しかし
、私はこれでAddXY
を交換することにより、グループそれらにテキストラベルを使用しようとするように変更:
connectedTimeRangeSeries.Points.AddXY(theLabel, timeRanges[i].StartConnectionTime, timeRanges[i].StopConnectionTime);
時間範囲は、下のグラフのインデックスに応じてグループ化されています
データは、もはやグループ化されていません:
それはようなものですそれぞれは独自のビンを取得し、ラベルで結合するだけです。 (各インデックスにはラベルが1つしかありません)
アイデアはありますか?ありがとう!
あなたはconnectedTimeRangeSeries.Points.AddXY(theLabel、timeRangeは[i]を.StartConnectionTime、timeRangeは[i]の.StopConnectionTime)を行うにはどうすればよいです。 2つの値で私は1つの値しか持てないと言っています。 –