Hi
I generate some graphs with elliptical boundaries around data points (see attachment with magenta ellipses). These ellipses represent, say, 1 sigma uncertainties for individual data points. I would like to be able to colour the interior of each ellipse, with variable opacity and maybe gradient according to values in some other variable in a dataset.
Please could you advise me whether there is currently any option in TeeChart to fill inside some calculated/defined boundary (like the ellipses in the attached image) and whether it would also be possible to colour according to a third data variable?
Any advice for how to achieve this (if possible with current versions of TeeChart) would be much appreciated.
Thanks
Bruce
Filling within outlines on graphs
Re: Filling within outlines on graphs
Hello Bruce,
You could take the point values that you use to plot the data, converting them to pixel locations using:
Before you plot the polygon, set the Brush to fill as you require.
eg.
Regards,
Marc Meumann
You could take the point values that you use to plot the data, converting them to pixel locations using:
..or loop through the indexes of the points using:Series1.CalcXPosValue(value) and Series1.CalcYPosValue(value)
..and adding them to an array of TPoints. You can then plot the array in the OnAfterDraw event using:Series1.CalcXPos(idx) and Series1.CalcYPos(idx)
Code: Select all
Chart1.Canvas.Polygon(yourArray);
eg.
Code: Select all
Chart1.Canvas.Brush.Gradient.StartColor := clRed; //can use (a)rgb colours
Chart1.Canvas.Brush.Gradient.EndColor := clYellow;
Chart1.Canvas.Brush.Gradient.Visible := True;
Chart1.Canvas.Polygon(yourArray);
Marc Meumann
Steema Support
Re: Filling within outlines on graphs
Thanks. I am missing something though and am not sure what the associations are.
What is the array definition meant to be? is it something like
or should this be TPoints, in which case TPoints must be defined in some unit I am not aware of.
When adding the pixel location data to the array, I presume that this should be something like
but this does not seem to work.
Any help would be much appreciated
Thanks
Bruce
What is the array definition meant to be? is it something like
Code: Select all
MyArray : array of TPoint;
When adding the pixel location data to the array, I presume that this should be something like
Code: Select all
for i := 1 to N // N is count for existing Series dataset
MyArray[i].Create(Xloc,Yloc);
end;
Any help would be much appreciated
Thanks
Bruce
Bruce
Re: Filling within outlines on graphs
Hello Bruce,
This example would go some way to the goal, proof of concept. You can make adjustments as necessary:
Regards,
Marc
This example would go some way to the goal, proof of concept. You can make adjustments as necessary:
Code: Select all
procedure TForm1.Chart1AfterDraw(Sender: TObject);
var i : Integer;
myPoints : Array of TPoint;
begin
Chart1.Canvas.Brush.Gradient.StartColor := clRed; //can use (a)rgb colours
Chart1.Canvas.Brush.Gradient.EndColor := clYellow;
Chart1.Canvas.Brush.Gradient.Visible := True;
SetLength(myPoints, Series1.Count);
for i:= 0 to Series1.Count-1 do
Begin
myPoints[i] := TPoint.Create(Series1.CalcXPos(i),Series1.CalcYPos(i));
End;
Chart1.Canvas.Polygon(myPoints);
end;
Marc