【问题标题】:Multiple Y axis Labels/Title overlap each others多个 Y 轴标签/标题相互重叠
【发布时间】:2020-01-27 12:26:46
【问题描述】:

我使用以下代码显示图表的多个 Y 轴。当任何轴标签值超过 3 位时,该轴标签/标题与其他轴标签重叠(如图所示)。

int leftIndex = 0, rightIndex = 0;
int relativePosition = 0;                 
foreach (Steema.TeeChart.Axis axis in this.tChart.Axes.Custom)
    {                       
    axis.Visible = true;

    axis.PositionUnits = Steema.TeeChart.PositionUnits.Pixels;

    axis.RelativePosition = 0 - (axis.OtherSide ? rightIndex++ : leftIndex++) * 60;

    relativePosition = relativePosition + (axis.AxisRect().Width + 60);

    }

【问题讨论】:

    标签: c# overlap teechart


    【解决方案1】:

    您应该能够通过稍微修改计算中的常数来正确呈现图表,例如

    TChart _tChart;
    public Form1()
    {
        InitializeComponent();
    
        _tChart = new TChart();
        _tChart.Dock = DockStyle.Fill;
    
        _tChart.Series.Add(typeof(Line)).FillSampleValues();
        _tChart.Series.Add(typeof(Line)).FillSampleValues();
        _tChart.Series.Add(typeof(Line)).FillSampleValues();
    
        _tChart.Series[0].YValues.Value = _tChart.Series[2].YValues.Value.Select(x => x * 100).ToArray();
    
        _tChart.Header.Text = Utils.Version;
        _tChart[0].CustomVertAxis = _tChart.Axes.Custom.Add();
        _tChart[0].CustomVertAxis.Title.Text = "Axis One Title";
        _tChart[0].CustomVertAxis.Title.Angle = 90;
    
        _tChart[1].CustomVertAxis = _tChart.Axes.Custom.Add();
        _tChart[1].CustomVertAxis.Title.Text = "Axis Two Title";
        _tChart[1].CustomVertAxis.Title.Angle = 90;
    
        _tChart[2].CustomVertAxis = _tChart.Axes.Custom.Add();
        _tChart[2].CustomVertAxis.Title.Text = "Axis Three Title";
        _tChart[2].CustomVertAxis.Title.Angle = 90;
    
        int leftIndex = 0, rightIndex = 0;
    
        for (int i = 0; i < this._tChart.Axes.Custom.Count; i++)
        {
            var axis = this._tChart.Axes.Custom[i];
            axis.Visible = true;
            axis.PositionUnits = Steema.TeeChart.PositionUnits.Pixels;
            axis.RelativePosition = 0 - (axis.OtherSide ? rightIndex++ : leftIndex++) * (i == 1 ? 80: 70);
        }
    
    
        _tChart.Panel.MarginLeft = 30;
        this.Controls.Add(_tChart);
    }
    

    这给了我:

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2020-09-20
      • 2021-01-22
      • 2012-03-14
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-07-28
      相关资源
      最近更新 更多