Changing the attributes of Point on a Line Chart

TeeChart VCL for Borland/CodeGear/Embarcadero RAD Studio, Delphi and C++ Builder.
Post Reply
DataInspector
Newbie
Newbie
Posts: 3
Joined: Wed Aug 17, 2011 12:00 am

Changing the attributes of Point on a Line Chart

Post by DataInspector » Tue Jan 31, 2012 10:51 pm

I developed a Delphi App a few years ago that allows my users to plot chemistry data as time series plots (line charts). Is it possible to change the attributes of individual points as they are being added to the chart so that they will appears as a different shape (psCircle, or psStar), based on the content of another data field. For instance, if the chemical is "Detected" the shape would be psCircle. If the chemical is "Not Detected" the shape would be psStar. When I tried this before, I believe it it changed all of the shapes based on the last final point added.

Listed below is the code I currently use. Remnants of my attempted code at the time has been commented out.

Thanks

Code: Select all

procedure TfmAnalyticalGraphs.FillSampleSeries;
Var
  AnalyteSeries : TLineSeries;
  NameNew, NameOld: String;
Begin
 ChartTSByAnalyte.SeriesList.Clear;
 ClientDSTimeSeriesByAnalyte.Filtered := False;
 ClientDSTimeSeriesByAnalyte.Filter := 'ANALYTE = '+QuotedStr(AnalyteName);
 ClientDSTimeSeriesByAnalyte.Filtered := True;
     with ClientDSTimeSeriesByAnalyte do
       begin
        DisableControls;
         try
          First;
          NameNew := ClientDSTimeSeriesByAnalyteSAMPLE_NAME.AsString;
            while not(EOF) do
             Begin
              NameOld := NameNew;
              AnalyteSeries := TLineSeries.Create(Self);
              AnalyteSeries.ParentChart := chartTSByAnalyte;
              AnalyteSeries.Title := NameNew;
              AnalyteSeries.pointer.Style := psCircle;
              AnalyteSeries.Pointer.Visible := True;
              AnalyteSeries.XValues.DateTime := True;
              chartTSByAnalyte.Axes.Bottom.DateTimeFormat := 'mm/dd/yy';
              chartTSByAnalyte.Axes.Left.AxisValuesFormat := '0.00';

            while NameOld = NameNew do
              begin
                AnalyteSeries.AddXY(FindField('SAMPLE_DATE').AsDateTime, FindField('RESULT').AsFloat);
               //      if FindField('DETECTED').AsString = 'No' then
                //      begin
                 //     SampleSeries.OnGetPointerStyle;
                   //   result := psStar;
                   //   end
                   //    else
                   //   SampleSeries.OnGetPointerStyle()
                   //   result := psCircle;
                    if Not (EOF) then
                      Begin
                       next;
                       NameNew := FindField('SAMPLE_NAME').AsString; //Get Sample Name
                      end
                      else
                       Break;
                end
          end
       finally
      EnableControls;
       end
    end
end;


Yeray
Site Admin
Site Admin
Posts: 9612
Joined: Tue Dec 05, 2006 12:00 am
Location: Girona, Catalonia
Contact:

Re: Changing the attributes of Point on a Line Chart

Post by Yeray » Wed Feb 01, 2012 12:21 pm

Hi,

You should use the TPointSeries OnGetPointerStyle to achieve it. This event is fired each time a value in the assigned series is going to be fired allowing you to assign a different PointerStyle to each point.
You can see an example of it in the features demo at "All features\Welcome !\Chart styles\Extended\Point 3D\Pointer style event".
Best Regards,
ImageYeray Alonso
Development & Support
Steema Software
Av. Montilivi 33, 17003 Girona, Catalonia (SP)
Image Image Image Image Image Image Please read our Bug Fixing Policy

Post Reply