標籤:
我用的是C# 從網上看到資料拷貝過來備忘,共同學習下:
- 設定chart標題:axTChart1.Header.Text.Add("標題");
- 修改標題:axTChart1.Header.Text.set_Item(index, "修改後的標題");
- 表頭標題清除: axTChart1.Header.Text.Clear();
- 移除第n(int)個標題:axTChart1.Header.Text.Remove(1);
- 標題置中:axTChart1.Header.Alignment = TeeChart.ETitleAlignment.taCenter;
- 標題向右移動50:axTChart1.Header.CustomPosition = true;
axTChart1.Header.Left= axTChart1.Header.Left + 50;
- 標題背景:axTChart1.Header.Transparent = false;//背景不透明
axTChart1.Header.Brush.Style = TeeChart.EBrushStyle.bsBackCrossSmall;//背景樣式
- 標題背景陰影顏色:axTChart1.Header.Transparent = false;
axTChart1.Header.ShadowColor=(uint)(1255);
說明(Legend):
- 說明是否可見:axTChart1.Legend.Visible = true;
- 說明框內分割線是否可見:axTChart1.Legend.DividingLines.Visible = true;
- 說明框分割線顏色:axTChart1.Legend.Color=(uint)(2201);
- 說明框向下移位(量50):TChart1.Legend.TopPos =50
- 說明框內圖示的長度:axTChart1.Legend.ColorWidth = 150;
- 說明框內文字顏色:axTChart1.Legend.Font.Color = (uint)(130000);
- 說明框陰影部分的顏色和深度:axTChart1.Legend.ShadowColor=(uint)(13000);
axTChart1.Legend.ShadowSize = 6;
面板(Panel):
- 載入面板背景圖片:axTChart1.Panel.BackImageLoad(@"e:\121.jpg");
- 面板斜度設定:
?
| 1234 |
axTChart1.Panel.Gradient.Visible = true;axTChart1.Panel.Gradient.StartColor = (uint)(1);axTChart1.Panel.Gradient.EndColor = (uint)(13000);axTChart1.Panel.Gradient.Direction = TeeChart.EGradientDirection.gdFromTopLeft; |
3D效果:
- 隱藏3D效果:axTChart1.Aspect.View3D = false;
Chart分頁:
- 運行時顯示ChartEditor對話方塊:axTChart1.ShowEditor();
- 每一頁最多可以顯示的點的數量:axTChart1.Page.MaxPointsPerPage = 20;
- 下一頁&&上一頁(這時需要設定一個按鈕來完成): axTChart1.Page.Next();
axTChart1.Page.Previous();
- 跳到最後一頁:axTChart1.Page.Current = axTChart1.Page.Count;
- 決定最後一頁放縮:axTChart1.Page.ScaleLastPage = false;
- 擷取當前頁碼:MessageBox.Show(axTChart1.Page.Current.ToString());
座標(Axis):
- 添加20個點到序列上:?
| 1234567 |
for (int i = 1; i <= 20; i++) { axTChart1.Series(1).Add(i*i, i.ToString(), (uint)(50000)); } |
- 設定軸刻度(Y軸為Axis.Left ,X軸為Axis.Bottom)
- 設定Y軸的終點和起點,最小刻度值:
?
| 1234 |
axTChart1.Axis.Left.Automatic = false;//必須有,或者用.AutomaticMaximum等代替axTChart1.Axis.Left.Maximum = 600;//最大值的聲明必須在最小值先,否則報錯axTChart1.Axis.Left.Minimum = 500;axTChart1.Axis.Left.Increment = 20; |
- 將Y軸最小值固定,最大值自動成長:出現嚴重錯誤
- 將Y軸最大值固定,最小值自動時應:
?
| 123 |
axTChart1.Axis.Left.AutomaticMaximum = false;axTChart1.Axis.Left.Maximum = 600;axTChart1.Axis.Left.AutomaticMinimum = true; |
(* 結論: 在設定最大最小值時,沒設定最大值就設定最小值將失敗)
自訂軸標籤(添加軸事件):
?
| 123 |
private void axTChart1_OnGetAxisLabel(object sender, AxTeeChart.ITChartEvents_OnGetAxisLabelEvent e) {e.labelText = "p" + e.valueIndex.ToString();} |
設定軸自訂標籤:
?
| 1234 |
axTChart1.Axis.Left.Logarithmic = true;axTChart1.Axis.Left.Increment = 0;//預設為0axTChart1.Axis.Left.SetMinMax(0, 10000);axTChart1.Axis.Left.Labels.ValueFormat = "#e+0"; |
自訂交叉座標軸:只能在chart Editor中設定。
座標軸點擊事件:
?
| 12345 |
private void axTChart1_OnClickAxis(object sender, AxTeeChart.ITChartEvents_OnClickAxisEvent e){MessageBox.Show(axTChart1.Axis.Bottom.CalcPosPoint(e.x).ToString());//顯示位置 } |
Series:
- 刪除第5個點(從0開始):axTChart1.Series(0).Delete(5);
- 添加一個座標:axTChart1.Series(0).AddNull("label");
- 添加一個Series:
?
| 1234 |
TeeChart.ESeriesClass ns = new TeeChart.ESeriesClass();int index = axTChart1.AddSeries(ns);axTChart1.Series(index).HorizontalAxis = TeeChart.EHorizontalAxis.aTopAxis;axTChart1.Series(index).VerticalAxis = TeeChart.EVerticalAxis.aRightAxis; |
?
| 12 |
axTChart1.Series(1).DataSource = "Series0";axTChart1.Series(1).SetFunction(TeeChart.EFunctionType.tfCopy); |
?
| 1 |
axTChart1.ExchangeSeries(0, 1); //After exchanging Series, the index for the Series will be changed. |
- 顯示第三個位置的Y值:MessageBox.Show(axTChart1.Series(0).YValues.get_Value(3).ToString());
- 修改第9個位置的Y值為21:axTChart1.Series(0).YValues.set_Value(int.Parse(9,21);
- 將第有個位置的座標向X軸正向移動5個座標:axTChart1.Series(0).XValues.set_Value(5,9);
- 清除繪圖:axTChart1.Series(0).Clear();
- 清除刻度:axTChart1.Axis.Visible = false;
- 清除底部刻度:axTChart1.Axis.Bottom.Visible = false;
- Margin和左邊相距 20% :axTChart1.Panel.MarginLeft = 20;
TeeChart常用編程語句匯總(C#)