データ系列内の空文字をチャート上で非表示にしたい

文書番号 : 38812     文書種別 : 使用方法     登録日 : 2015/06/24     最終更新日 : 2015/12/16
文書を印刷する
対象製品
SPREAD for Windows Forms 8.0J
詳細
デフォルトでは、データ系列内の空文字はチャート上でゼロ値として扱われます。この表示を変更するには、チャートオブジェクトのDataSettingプロパティを指定します。

◎サンプルコード(VB)
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
  ' データの設定
  FpSpread1.ActiveSheet.SetValue(0, 0, 1)
  FpSpread1.ActiveSheet.SetValue(1, 0, 2)
  FpSpread1.ActiveSheet.SetValue(2, 0, 3)
  FpSpread1.ActiveSheet.SetValue(3, 0, Nothing)
  FpSpread1.ActiveSheet.SetValue(4, 0, 5)
  FpSpread1.ActiveSheet.SetValue(5, 0, 6)

  ' 折れ線グラフの作成
  Dim series1 As New FarPoint.Win.Chart.LineSeries()
  series1.PointMarker = New FarPoint.Win.Chart.BuiltinMarker(FarPoint.Win.Chart.MarkerShape.Circle, 8.0F)
  series1.Values.DataSource = New FarPoint.Win.Spread.Chart.SeriesDataField(FpSpread1, "Values", "Sheet1!$A$1:$A$6")

  ' プロットエリアの作成
  Dim PlotArea As New FarPoint.Win.Chart.YPlotArea()
  PlotArea.Location = New PointF(0.2F, 0.2F)
  PlotArea.Size = New SizeF(0.6F, 0.6F)
  PlotArea.Series.Add(series1)

  ' チャートの作成
  Dim chart1 = New FarPoint.Win.Spread.Chart.SpreadChart()
  chart1.ChartName = "chart1"
  chart1.Size = New Size(300, 180)
  chart1.Location = New Point(120, 20)
  ' データ系列内の空文字をチャート上で非表示にする
  chart1.DataSetting = New FarPoint.Win.Spread.Chart.ChartDataSetting(FarPoint.Win.Spread.Chart.EmptyValueStyle.Gaps, False)

  Dim Model As New FarPoint.Win.Chart.ChartModel()
  Model.PlotAreas.Add(PlotArea)
  chart1.Model = Model
  FpSpread1.ActiveSheet.Charts.Add(chart1)
End Sub


◎サンプルコード(C#)
private void Form1_Load(object sender, EventArgs e)
{
  // データの設定
  fpSpread1.ActiveSheet.SetValue(0, 0, 1);
  fpSpread1.ActiveSheet.SetValue(1, 0, 2);
  fpSpread1.ActiveSheet.SetValue(2, 0, 3);
  fpSpread1.ActiveSheet.SetValue(3, 0, null);
  fpSpread1.ActiveSheet.SetValue(4, 0, 5);
  fpSpread1.ActiveSheet.SetValue(5, 0, 6);

  // 折れ線グラフの作成
  FarPoint.Win.Chart.LineSeries series1 =new FarPoint.Win.Chart.LineSeries();
  series1.PointMarker = new FarPoint.Win.Chart.BuiltinMarker(FarPoint.Win.Chart.MarkerShape.Circle, 8.0F);
  series1.Values.DataSource = new FarPoint.Win.Spread.Chart.SeriesDataField(fpSpread1, "Values", "Sheet1!$A$1:$A$6");

  // プロットエリアの作成
  FarPoint.Win.Chart.YPlotArea PlotArea = new FarPoint.Win.Chart.YPlotArea();
  PlotArea.Location = new PointF(0.2F, 0.2F);
  PlotArea.Size = new SizeF(0.6F, 0.6F);
  PlotArea.Series.Add(series1);

  // チャートの作成
  FarPoint.Win.Spread.Chart.SpreadChart chart1 = new FarPoint.Win.Spread.Chart.SpreadChart();
  chart1.ChartName = "chart1";
  chart1.Size = new Size(300, 180);
  chart1.Location = new Point(120, 20);
  // データ系列内の空文字をチャート上で非表示にする
  chart1.DataSetting = new FarPoint.Win.Spread.Chart.ChartDataSetting(FarPoint.Win.Spread.Chart.EmptyValueStyle.Gaps, false);

  FarPoint.Win.Chart.ChartModel Model = new FarPoint.Win.Chart.ChartModel();
  Model.PlotAreas.Add(PlotArea);
  chart1.Model = Model;
  fpSpread1.ActiveSheet.Charts.Add(chart1);
}
関連情報
キーワード
チャート