2013-02-04 163 views
0

我是C#編程新手。我在一家公司工作,有人完成了一些任務,並留下了圖表部分。現在我必須這樣做。我想在圖表的左側(y軸)和comman x軸爲所有人創建多軸座標圖。從側面的每個軸將是不同的軸長度。Teechart多軸創建

我已經爲不同的傳感器創建了六個複選框,當我勾選該框時,應該出現關於具有默認長度軸的軸。我創建了複選框,但我無法設置軸長度,也無法繪製多個軸。

我不知道這是正確的方式問?如果我錯了,請原諒我?如果我沒有提供很多信息,那麼請問我,我會做到這一點。

我想繪製圖表的類型,如附圖所示。 X軸(系統時間)對於所有系列都是通用的,而Y軸對於每個系列都是不同的。我有所有系列的框,所以當勾選複選框時,系列Y軸必須顯示默認的軸範圍(例如min(0)和max(1000))。 chart

在此先感謝。

回答

1

在Steema支持論壇上討論過一些非常相似的東西。 看一看here

我張貼在這裏相同的代碼:

int nSeries = 3; 
    private void InitializeChart() 
    { 
     tChart1.Aspect.View3D = false; 
     tChart1.Header.Visible = false; 
     tChart1.Legend.Alignment = LegendAlignments.Bottom; 
     for (int i = 0; i < nSeries; i++) 
     { 
      new Steema.TeeChart.Styles.Line(tChart1.Chart); 
      tChart1.Axes.Custom.Add(new Steema.TeeChart.Axis(tChart1.Chart)); 
      tChart1[i].CustomVertAxis = tChart1.Axes.Custom[i]; 
      tChart1.Axes.Custom[i].AxisPen.Color = tChart1[i].Color; 
      tChart1.Axes.Custom[i].Grid.Visible = false; 
      tChart1.Axes.Custom[i].Title.Visible = true; 
      tChart1.Axes.Custom[i].Title.Caption = "Series" + i.ToString(); 
      tChart1[i].FillSampleValues(20); 
      tChart1.Axes.Custom[i].PositionUnits = PositionUnits.Pixels; 
     } 

     tChart1.Panel.MarginUnits = PanelMarginUnits.Pixels; 
     tChart1.Draw(); 
     PlaceAxes(0, 0, 0, 0, 0); 
     tChart1.Draw(); 
    } 

    private void PlaceAxes(int nSeries, int NextXLeft, int NextXRight, int MargLeft, int MargRight) 
    { 
     const int extraPos = 12; 
     const int extraMargin = 105; 
     //Variable 
     int MaxLabelsWidth; 
     int lenghtTicks; 
     int extraSpaceBetweenTitleAndLabels; 
     if (tChart1[nSeries].Active) 
     { 
      MaxLabelsWidth = tChart1.Axes.Custom[nSeries].MaxLabelsWidth(); 
      lenghtTicks = tChart1.Axes.Custom[nSeries].Ticks.Length; 
      extraSpaceBetweenTitleAndLabels = (tChart1.Axes.Custom[nSeries].Title.Width);//- tChart1.Axes.Custom[nSeries].MaxLabelsWidth()); 
      if (tChart1.Axes.Custom[nSeries].OtherSide) 
      { 
       tChart1.Axes.Custom[nSeries].RelativePosition = NextXRight; 
       NextXRight = NextXRight - (MaxLabelsWidth + lenghtTicks + extraSpaceBetweenTitleAndLabels + extraPos); 
       MargRight = MargRight + extraMargin; 
      } 

      else 
      { 
       tChart1.Axes.Custom[nSeries].RelativePosition = NextXLeft; 
       NextXLeft = NextXLeft - (MaxLabelsWidth + lenghtTicks + extraSpaceBetweenTitleAndLabels + extraPos); 
       MargLeft = MargLeft + extraMargin; 
      } 

      tChart1.Panel.MarginLeft = MargLeft; 
      tChart1.Panel.MarginRight = MargRight; 

      nSeries++; 

      if (nSeries <= tChart1.Series.Count - 1) 
      { 
       PlaceAxes(nSeries, NextXLeft, NextXRight, MargLeft, MargRight); 
      } 
     } 
    } 
+0

我使用上面的代碼得到錯誤,這是「N系列」中的方法intilizechart不存在();你已經在PlaceAxes()方法中聲明瞭。你怎麼稱呼它,我可以在全球範圍內申報。 – PRV

+0

對於這個例子'nSeries'只是一個'int'(系列號)。我編輯了回覆中的代碼以初始化它。 – Yeray