MESCIUS SPREAD for Windows Forms 17.0J サンプルコード集
チャートに複数レベルの項目軸ラベルを追加する

IndexAxisクラスのMultiLevelプロパティをTrueにすることで複数レベルの項目軸ラベルを有効にできます。この機能によりチャートに含まれる軸のラベルを複数段で表示することが可能です。

  • 新しいスタイルシステム(LegacyBehaviorsプロパティがStyleを含まない場合)で有効です。
  • 拡張シェイプエンジン(EnhancedShapeEngineプロパティ)を有効にする必要があります。

【実行例】

private void Form1_Load(object sender, EventArgs e)
 {
  // データを設定します
  fpSpread1.AsWorkbook().ActiveSheet.Cells[0, 2].Value = "S1";
  fpSpread1.AsWorkbook().ActiveSheet.Cells[0, 3].Value = "S2";
  fpSpread1.AsWorkbook().ActiveSheet.Cells[0, 4].Value = "S3";

  fpSpread1.AsWorkbook().ActiveSheet.Cells[1, 0].Value = "FY";

  fpSpread1.AsWorkbook().ActiveSheet.Cells[1, 1].Value = "1Q";
  fpSpread1.AsWorkbook().ActiveSheet.Cells[2, 1].Value = "2Q";
  fpSpread1.AsWorkbook().ActiveSheet.Cells[3, 1].Value = "3Q";
  fpSpread1.AsWorkbook().ActiveSheet.Cells[4, 1].Value = "4Q";

  fpSpread1.AsWorkbook().ActiveSheet.Cells[1, 2].Value = 50;
  fpSpread1.AsWorkbook().ActiveSheet.Cells[2, 2].Value = 30;
  fpSpread1.AsWorkbook().ActiveSheet.Cells[3, 2].Value = 20;
  fpSpread1.AsWorkbook().ActiveSheet.Cells[4, 2].Value = 40;

  fpSpread1.AsWorkbook().ActiveSheet.Cells[1, 3].Value = 30;
  fpSpread1.AsWorkbook().ActiveSheet.Cells[2, 3].Value = 15;
  fpSpread1.AsWorkbook().ActiveSheet.Cells[3, 3].Value = 50;
  fpSpread1.AsWorkbook().ActiveSheet.Cells[4, 3].Value = 20;

  fpSpread1.AsWorkbook().ActiveSheet.Cells[1, 4].Value = 10;
  fpSpread1.AsWorkbook().ActiveSheet.Cells[2, 4].Value = 40;
  fpSpread1.AsWorkbook().ActiveSheet.Cells[3, 4].Value = 25;
  fpSpread1.AsWorkbook().ActiveSheet.Cells[4, 4].Value = 25;

  // データ領域およびスタイルを指定してチャートを設定します  
  FarPoint.Win.Spread.Model.CellRange range = new FarPoint.Win.Spread.Model.CellRange(0, 0, 5, 5);
  fpSpread1.Sheets[0].AddChart(range, typeof(FarPoint.Win.Chart.LineSeries), 250, 200, 250, 110, FarPoint.Win.Chart.ChartViewType.View2D, true);
  FarPoint.Win.Chart.YPlotArea plotArea = (FarPoint.Win.Chart.YPlotArea)(fpSpread1.Sheets[0].Charts[0].Model.PlotAreas[0]);

  // 複数レベルの項目軸ラベルを有効にします
  plotArea.XAxis.MultiLevel = true;
 }
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
  ' データを設定します
  FpSpread1.AsWorkbook().ActiveSheet.Cells(0, 2).Value = "S1"
  FpSpread1.AsWorkbook().ActiveSheet.Cells(0, 3).Value = "S2"
  FpSpread1.AsWorkbook().ActiveSheet.Cells(0, 4).Value = "S3"

  FpSpread1.AsWorkbook().ActiveSheet.Cells(1, 0).Value = "FY"

  FpSpread1.AsWorkbook().ActiveSheet.Cells(1, 1).Value = "1Q"
  FpSpread1.AsWorkbook().ActiveSheet.Cells(2, 1).Value = "2Q"
  FpSpread1.AsWorkbook().ActiveSheet.Cells(3, 1).Value = "3Q"
  FpSpread1.AsWorkbook().ActiveSheet.Cells(4, 1).Value = "4Q"

  FpSpread1.AsWorkbook().ActiveSheet.Cells(1, 2).Value = 50
  FpSpread1.AsWorkbook().ActiveSheet.Cells(2, 2).Value = 30
  FpSpread1.AsWorkbook().ActiveSheet.Cells(3, 2).Value = 20
  FpSpread1.AsWorkbook().ActiveSheet.Cells(4, 2).Value = 40

  FpSpread1.AsWorkbook().ActiveSheet.Cells(1, 3).Value = 30
  FpSpread1.AsWorkbook().ActiveSheet.Cells(2, 3).Value = 15
  FpSpread1.AsWorkbook().ActiveSheet.Cells(3, 3).Value = 50
  FpSpread1.AsWorkbook().ActiveSheet.Cells(4, 3).Value = 20

  FpSpread1.AsWorkbook().ActiveSheet.Cells(1, 4).Value = 10
  FpSpread1.AsWorkbook().ActiveSheet.Cells(2, 4).Value = 40
  FpSpread1.AsWorkbook().ActiveSheet.Cells(3, 4).Value = 25
  FpSpread1.AsWorkbook().ActiveSheet.Cells(4, 4).Value = 25

  ' データ領域およびスタイルを指定してチャートを設定します  
  Dim range As FarPoint.Win.Spread.Model.CellRange = New FarPoint.Win.Spread.Model.CellRange(0, 0, 5, 5)
  FpSpread1.Sheets(0).AddChart(range, GetType(FarPoint.Win.Chart.LineSeries), 250, 200, 250, 110, FarPoint.Win.Chart.ChartViewType.View2D, True)
  Dim plotArea As FarPoint.Win.Chart.YPlotArea = FpSpread1.Sheets(0).Charts(0).Model.PlotAreas(0)

  ' 複数レベルの項目軸ラベルを有効にします
  plotArea.XAxis.MultiLevel = True
 End Sub

 

 


© MESCIUS inc. All rights reserved.