close

每次看到別人的TChart圖表 就覺得delphi預設的真的很詭異阿 醜到一個不行的,

 

但應該是我不太會用因此這兩天認真的決定拿一個範本 希望能做的跟他差不多吧 

 

 

就拿匹克幫首頁的這個吧

 

施工完畢後

 

 

 

程式碼如下 


 

var
  i, Max: Integer;
  mPOINT:TSeriesPointerItems;
  Series1, Series2 : TLineSeries ;
begin

  Chart1.SeriesList.Clear;
  //左下邊線顏色
  Chart1.LeftAxis.Axis.Color := TAlphaColor($55999999);
  Chart1.BottomAxis.Axis.Color := TAlphaColor($55999999);
//  Chart1.Series.Color := TAlphaColor($FF27A1D5);

  { TODO : 第一條線 }
  Series1 := TLineSeries.Create(Self);
  Series1.ParentChart := Chart1;
  Series1.Pointer.Visible := True;
  Series1.Pointer.Style := psCircle ;
  Series1.SeriesColor := TAlphaColor($3327A1D5);
  Series1.Pointer.Color := TAlphaColor($3327A1D5);
  Series1.LinePen.Width := 3;
//  Series1.LinePen.Style := TPenStyle.psSolid;
  Series1.Emboss.Visible:= False;
  Series1.Dark3D := False;
  Series1.Active := True;


  { TODO : 第二條線 }
  Series2 := TLineSeries.Create(Self);
  Series2.ParentChart := Chart1;
  Series2.Dark3D := False;
  Series2.VertAxis := aLeftAxis; // 左邊Y軸
  Series2.Active:=True;
  //線的顏色
//  Series2.SeriesColor := TAlphaColor($FF27A1D5);

  Series2.LinePen.Width := 3;
  //關閉線條的變色
  Series2.Emboss.Visible:= False;


//  Series2
  //點的顏色及設定

  Series2.Pointer.Visible:=True;
  Series2.Pointer.Style := psCircle ;
  Series2.Pointer.Color := TAlphaColor($FF27A1D5);
  Series2.Pointer.Pen.Width := 3;
  series2.Pointer.Pen.Color := TAlphaColor($FF27A1D5);
  Series2.Pointer.Emboss.Visible:= False;


  //GRID顏色改淡一點
  Chart1.Axes.Left.Grid.Color :=  TAlphaColor($55999999);
  Chart1.Axes.Bottom.Grid.Color :=  TAlphaColor($55999999);

  //編寫資料
  Chart1[1].Add(100, '', clTeeColor);
  Chart1.Axes.Bottom.LabelStyle:=talText;
  Chart1[1].Add(40, '', clTeeColor);
  Chart1.Axes.Bottom.LabelStyle:=talText;
  Chart1[1].Add(70, '', clTeeColor);
  Chart1.Axes.Bottom.LabelStyle:=talText;
  Chart1[1].Add(140, '', clTeeColor);
  Chart1.Axes.Bottom.LabelStyle:=talText;
  Chart1[1].Add(80, '', clTeeColor);
  Chart1.Axes.Bottom.LabelStyle:=talText;
  Chart1[1].Add(150, 'MAX', clTeeColor);
  Chart1.Axes.Bottom.LabelStyle:=talText;

  //編寫X軸的顯示
  Chart1.Axes.Bottom.Items.Clear;
  for i:=0 to Chart1[1].Count-1 do
    Chart1.Axes.Bottom.Items.Add(Chart1[1].XValue[i], FormatDatetime('mm/dd', now-(7-i)));

  //編寫資料
  Chart1[0].Add(90, '', clTeeColor);
  Chart1.Axes.Bottom.LabelStyle:=talText;
  Chart1[0].Add(20, '', clTeeColor);
  Chart1.Axes.Bottom.LabelStyle:=talText;
  Chart1[0].Add(88, '', clTeeColor);
  Chart1.Axes.Bottom.LabelStyle:=talText;
  Chart1[0].Add(71, '', clTeeColor);
  Chart1.Axes.Bottom.LabelStyle:=talText;
  Chart1[0].Add(133, '', clTeeColor);
  Chart1.Axes.Bottom.LabelStyle:=talText;
  Chart1[0].Add(200, '', clTeeColor);
  Chart1.Axes.Bottom.LabelStyle:=talText;

 

 

arrow
arrow
    全站熱搜

    kuraki5336 發表在 痞客邦 留言(0) 人氣()