0

我想绘制一个带有 MultiBars 风格的 Bar 系列作为 SelfStack。默认情况下 self stack bar y 轴值为 0 ,有什么办法可以更改 self stack bar 的默认 y 轴

  • 公共类 Bar_SelfStack { 私人 Steema.TeeChart.Styles.Bar bar1; 私有 System.ComponentModel.IContainer 组件 = null; 私人 Steema.TeeChart.TChart tChart1;私有 Steema.TeeChart.Tools.GridBand gridBand1;

           public Bar_SelfStack()
           {
               // This call is required by the Windows Form Designer.
               InitializeComponent();
    
               bar1.Add(100, "Cars");
               bar1.Add(300, "Phones");
               bar1.Add(200, "Lamps");
    
               // Set "Self-Stacked":
               bar1.MultiBar = Steema.TeeChart.Styles.MultiBars.SelfStack;
    
               // cosmetic
               bar1.Marks.Visible = false;
               bar1.Marks.Style = Steema.TeeChart.Styles.MarksStyles.Value;
               bar1.ColorEach = true;
           }
       }
    
4

1 回答 1

0

您可以将默认 Y 轴更改为自定义垂直轴,如下一个简单代码所示:

Steema.TeeChart.TChart tChart1; 
public Form1()
{
    InitializeComponent();
    tChart1 = new TChart();
    this.Controls.Add(tChart1);
    tChart1.Top = 150;
    tChart1.Left = 100;
    tChart1.Height = 400;
    tChart1.Width = 550; 
    InitializeChart();
}
Steema.TeeChart.Styles.Bar series1, series2, series3,series4;
Steema.TeeChart.Axis axis1; 

private void InitializeChart()
{
    tChart1.Aspect.View3D = false; 
    series1 = new Bar(tChart1.Chart);
    series2 = new Bar(tChart1.Chart);
    series3 = new Bar(tChart1.Chart);
    series4 = new Bar(tChart1.Chart); 
    axis1 = new Axis(tChart1.Chart);  
    tChart1.Axes.Custom.Add(axis1); 
    series1.FillSampleValues();
    series2.FillSampleValues();
    series3.FillSampleValues(); 
    series4.FillSampleValues();
    series1.Marks.Visible = false;
    series2.Marks.Visible = false;
    series3.Marks.Visible = false;
    series4.Marks.Visible = false; 
    axis1.RelativePosition = tChart1.Panel.MarginLeft -12;
    tChart1.Panel.MarginLeft = 10; 
    axis1.Horizontal = false;
    series1.CustomVertAxis = axis1;
    series1.MultiBar = MultiBars.SelfStack;
    button1.Click +=button1_Click;
}

您能否告诉我们以前的代码是否可以帮助您实现您想要的目标?

我希望会有所帮助。

谢谢,

于 2013-10-10T09:23:54.623 回答