Set color gradient based on time series
-
- Newbie
- Posts: 5
- Joined: Mon Sep 09, 2019 12:00 am
Set color gradient based on time series
How do I automatically set a color gradient based on date. I want to be able to visually establish a how my data set may have changed through time, specifically in a triangular plot.
Re: Set color gradient based on time series
Hello,
Could you please show us some image about what would you like to get?
Could you please show us some image about what would you like to get?
Best Regards,
Yeray Alonso Development & Support Steema Software Av. Montilivi 33, 17003 Girona, Catalonia (SP) | |
Please read our Bug Fixing Policy |
-
- Newbie
- Posts: 2
- Joined: Mon Aug 08, 2022 12:00 am
Re: Set color gradient based on time series
Attached is a concept
Here is the code I am currently using
Here is the code I am currently using
Code: Select all
/// This procedure relies on data in the FDMemTableTri to produce the Trilear
/// Chart. The user chooses three analytes from LookupList boxes and then uses
/// a RadioGroup Box to assign series based on Media, Sample Type, Location, etc.
/// FDMemTable is then indexed based on RadioGroup choice. The procedure then
/// runs through FDMemTableTri to get the data.
procedure TfmAnalyticalGraphs.FillTriPlotSeries;
Var
TriPlotSeries : TTernarySeries;
NameNew, NameOld: String; ///These variables are used to evaluate when the end of a series is reached, and then the name of the next series.
PStyle : TSeriesPointerStyle;
SeriesColor : TColor;
k, m : integer;
Begin
ChartTriPlot.SeriesList.Clear;
ChartTriPlot.Walls.Back.Hide;
ChartTriPlot.Gradient.Visible:=False;
ChartTriPlot.Color:=clWhite;
k := 0;
m := 0;
with TTernarySeries(ChartTriPlot.AddSeries(TTernarySeries)) do
begin
ShowInLegend:=False;
AddNull;
VertexTitles[0].Text := cxLookupComboBoxTriAnal2.EditText;
VertexTitles[1].Text := cxLookupComboBoxTriAnal3.EditText;
VertexTitles[2].Text := cxLookupComboBoxTriAnal1.EditText;
end;
///Set Index by Radio Group - These become the means of setting up series such as "By Media" or By "Sample Type".
///For example - "By Media" could produce four series called "Groundwater", "Soil", "Sediment", and "Surface Water"
FDMemTableTri.IndexesActive := False;
case cxRadioGroupTri.ItemIndex of
0 : FDMemTableTri.IndexFieldNames := 'Media_PK';
1 : FDMemTableTri.IndexFieldNames := 'Sample_Type_PK';
2 : FDMemTableTri.IndexFieldNames := 'Locations_PK';
3 : FDMemTableTri.IndexFieldNames := 'Sample_Event_PK';
4 : FDMemTableTri.IndexFieldNames := 'Sample_Date';
5 : FDMemTableTri.IndexFieldNames := 'Sample_Depth_Top';
6 : FDMemTableTri.IndexFieldNames := 'Inventory_PK';
7 : FDMemTableTri.IndexFieldNames := 'Sample_PK';
end;
FDMemTableTri.IndexesActive := True;
with FDMemTableTri do
begin
DisableControls;
try
First;
case cxRadioGroupTri.ItemIndex of
0 : NameNew := FDMemTableTriMEDIA.AsString;
1 : NameNew := FDMemTableTriSAMPLE_TYPE.AsString;
2 : NameNew := FDMemTableTriLOCATION.AsString;
3 : NameNew := FDMemTableTriSAMPLE_EVENT_NAME.AsString;
4 : NameNew := FDMemTableTriSAMPLE_DATE.AsString;
5 : NameNew := FDMemTableTriSAMPLE_DEPTH_TOP.AsString;
6 : NameNew := FDMemTableTriINVENTORY_NAME.AsString;
7 : NameNew := FDMemTableTriSAMPLE_NAME.AsString;
end;
while not(EOF) do
Begin
NameOld := NameNew;
with ChartTriPlot.AddSeries(TTernarySeries) as TTernarySeries do
begin
Title := NameOld;
UseColorRange:=False;
UsePalette:=False;
ColorEachPoint:=False;
pointer.Size := 10;
pointer.Visible := True;
case k of
0 : SeriesColor := clRed;
1 : SeriesColor := clBlue;
2 : SeriesColor := clLime;
3 : SeriesColor := clYellow;
4 : SeriesColor := clMaroon;
5 : SeriesColor := clTeal;
6 : SeriesColor := clFuchsia;
7 : SeriesColor := clBlack;
8 : SeriesColor := clAqua;
9 : SeriesColor := clNavy;
10 : SeriesColor := clGreen;
11 : SeriesColor := clPurple;
12 : SeriesColor := clGray;
13 : SeriesColor := clSilver;
14 : SeriesColor := clOlive;
15 : SeriesColor := clMoneyGreen;
16 : SeriesColor := clSkyBlue;
17 : SeriesColor := clMedGray;
end;
case m of
0 : PStyle := psDonut;
1 : PStyle := psRectangle;
2 : PStyle := psTriangle;
3 : PStyle := psDownTriangle;
4 : PStyle := psStar;
5 : PStyle := psDiamond;
6 : PStyle := psCross;
7 : PStyle := psDiagCross;
8 : PStyle := psLeftTriangle;
9 : PStyle := psRightTriangle;
10 : PStyle := psCircle;
end;
pointer.Style := PStyle;
pointer.Color := SeriesColor;
while NameOld = NameNew do
begin
if cxCheckBoxTriIgnoreND.Checked then //This is different than Cross Plot and Time Series. Here we assume a ND to be zero
AddXYZ(FindField('Analyte2Result').AsFloat, FindField('Analyte3Result').AsFloat, FindField('RESULT').AsFloat)
else //The fields listed below will be either the detected Result or 0
AddXYZ(FindField('Analyte2Result_ND').AsFloat, FindField('Analyte3Result_ND').AsFloat, FindField('RESULT_ND').AsFloat);
if Not (EOF) then
Begin
next;
case cxRadioGroupTri.ItemIndex of
0 : NameNew := FDMemTableTriMEDIA.AsString;
1 : NameNew := FDMemTableTriSAMPLE_TYPE.AsString;
2 : NameNew := FDMemTableTriLOCATION.AsString;
3 : NameNew := FDMemTableTriSAMPLE_EVENT_NAME.AsString;
4 : NameNew := FDMemTableTriSAMPLE_DATE.AsString;
5 : NameNew := FDMemTableTriSAMPLE_DEPTH_TOP.AsString;
6 : NameNew := FDMemTableTriINVENTORY_NAME.AsString;
7 : NameNew := FDMemTableTriSAMPLE_NAME.AsString;
end;
end
else
Break;
end;
inc(k);
if k = 18 then
begin
k := 0;
inc(m);
end;
end;
end;
finally
EnableControls;
end;
end;
end;
- Attachments
-
- Trilinear Plot.jpg (53.29 KiB) Viewed 15566 times
Re: Set color gradient based on time series
Hello,
I would use a
I would use a
TTernarySeries
and use ApplyBright
function to define the color of each point from the series base color and calculating the HowMuch
argument (0-255) depending on the date, probably coming from the database.Code: Select all
uses TeeTernary, TeCanvas;
procedure TForm1.FormCreate(Sender: TObject);
var i: Integer;
begin
Chart1.Align:=alClient;
Chart1.View3D:=False;
Chart1.Color:=clWhite;
Chart1.Gradient.Visible:=False;
Chart1.Walls.Back.Color:=clWhite;
Chart1.Walls.Back.Gradient.Visible:=False;
Chart1.Legend.Hide;
with TTernarySeries(Chart1.AddSeries(TTernarySeries)) do
begin
Pointer.Style:=psDonut;
Pointer.Size:=10;
UseColorRange:=False;
UsePalette:=False;
ColorEachPoint:=False;
FillSampleValues;
for i:=0 to Count-1 do
ValueColor[i]:=ApplyBright(Color, Round(random*255)); // change the second argument for a value date - dependant
end;
end;
Best Regards,
Yeray Alonso Development & Support Steema Software Av. Montilivi 33, 17003 Girona, Catalonia (SP) | |
Please read our Bug Fixing Policy |
-
- Newbie
- Posts: 2
- Joined: Mon Aug 08, 2022 12:00 am
Re: Set color gradient based on time series
Thanks for the advice. I couldn't find a lot of information for ApplyBright and have a question.
What are the range of integers allowed?
What are the range of integers allowed?
Re: Set color gradient based on time series
Hello,
It allows 0 to 255.
It allows 0 to 255.
Best Regards,
Yeray Alonso Development & Support Steema Software Av. Montilivi 33, 17003 Girona, Catalonia (SP) | |
Please read our Bug Fixing Policy |