Page 1 of 1

Changing the attributes of Point on a Line Chart

Posted: Tue Jan 31, 2012 10:51 pm
by 16460008
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;


Re: Changing the attributes of Point on a Line Chart

Posted: Wed Feb 01, 2012 12:21 pm
by yeray
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".