Line and Area Series
Q: Automatic Axes do not scale well with big line pen widths."A few months now, we're using the TeeChart component in Delphi3 with success. One little misbehaviour took our attention : when using the automatic scaling-option for X & Y axes, we saw that we can't see the max-values drawn in our chart on top or bottom(they are really there : you can see them when you drag the whole chart down)." You can expand the axis with the code
below. DELPHI CODE : With Chart1.LeftAxis do Maximum:=Maximum+Maximum*1.0/100.0; CBUILDER CODE : Chart1->LeftAxis->Maximum= Chart1->LeftAxis->Maximum+Chart1->LeftAxis->Maximum*0.01; Q: How can I plot a circle using a Line Series ?
DELPHI CODE : Var t:Integer; begin Series1.XValues.Order:=loNone ; for t:=0 to 360 do Series1.AddXY( Sin(t*Pi/180.0), Cos(t*Pi/180.0), '', clRed ); end; CBUILDER CODE : Series1->XValues->Order=loNone; for (int t=0;t<=360;t++) Series1->AddXY( sin(t*3.14/180.0), cos(t*3.14/180.0), "", clRed ); Q: I am trying to set the line style (Dotted, Dashed etc) for a Line Series at runtime in my code but cannot seem to get it right.
DELPHI CODE : Series1.LinePen.Style:=psDot; CBUILDER CODE : Series1.LinePen.Style=psDot; Q: Is there a simple way I can plot X-Y graph?
DELPHI CODE : Series1.LinePen.Visible:=False; CBUILDER CODE : Series1->LinePen->Visible=false; or use the TPoint series and AddXY method. Q: I use Chart.Series[0].Pointer.Visilble:=false It fails. How can I set points not visible at run-time?
DELPHI CODE : (Chart1.Series[0] as TLineSeries).Pointer.Visible:=false; CBUILDER CODE : if (dynamic_cast<TLineSeries*>(Chart1->Series[0])) dynamic_cast<TLineSeries*>(Chart1->Series[0])->Pointer->Visible=false; Q: With a diagonal hatching and the area lines set to invisible the diagonal lines are not continuous - but are broken where the data point are despite having the area lines set to invisible on the series. Is there anyway of overcoming this?This one can be handled with : DELPHI CODE : Series1.AreaLinesPen.Visible:=true; Series1.AreaLinesPen.Style:=psClear; CBUILDER CODE : Series1->AreaLinesPen->Visible=true; Series1->AreaLinesPen->Style=psClear; Q: Is there a way for a TLineSeries series to not start and end at the left and right axis?The TLineSeries.Pointer offers InflateMargins property. When set to true, the pointer horizontal and vertical size are taken into the account when axis min-max value is calculated. But if you don't want to display pointers, then you can : 1) Use TChartAxis SetMinMax method and set axis minimum and maximum value to [real_min-offset,real_max+offset]. The drawback is axis is not automatic anymore. 2) Use the simple trick : create a fake TPointSeries. Don't display it (by setting SeriesColor=clNone). Assign Series1 (original series displayed) values to fakeSeries. When the axis min-max value is calculated, the fakeSeries Pointer VertSize and HorizSize are taken into the account ==> you get offset: DELPHI CODE : var fakeSeries:TPointSeries; begin Series1.FillSampleValues(20); // original series // fake series fakeSeries:=TPointSeries.Create(self); fakeSeries.AssignValues(Series1); // get values from original series fakeSeries.Pointer.HorizSize:=5; // 5 pixels horizontal offest fakeSeries.Pointer.VertSize:=2; // 2 pixels vertical offset fakeSeries.Pointer.InflateMargins:=true; // must be true fakeSeries.ShowInLegend:=false; // we don't want it in legend fakeSeries.SeriesColor:=clNone; // nothing to see :) fakeSeries.ParentChart:=Series1.ParentChart; CBUILDER CODE : Series1->FillSampleValues(20); // original series // fake series TPointSeries *fakeSeries=new TPointSeries(this); fakeSeries->AssignValues(Series1); // get values from original series fakeSeries->Pointer->HorizSize=5; // 5 pixels horizontal offest fakeSeries->Pointer->VertSize=2; // 2 pixels vertical offset fakeSeries->Pointer->InflateMargins=true; // must be true fakeSeries->ShowInLegend=false; // we don't want it in legend fakeSeries->SeriesColor=clNone; // nothing to see :) fakeSeries->ParentChart=Series1->ParentChart; Q: Can I force the order how points are joined together in fastline series, avoiding ascending order as it is by default?
Yes. By default, the order is "ascending" on X values (horizontal).
VCL version: Series1.XValues.Order:=loNone ; ActiveX version: Chart1.Series(0).XValues.Order = loNone All points added after the above instruction will not be sorted. |