db aware TimeSeries Line Chart
db aware TimeSeries Line Chart
I have a D7 App that allows users to retrieve groundwater levels measured in wells over long periods of time. The data is organized by well, date, and water level elevation. How do I permit users to graph more than one well at a time (many series) in the correct time series position (not all wells are measured on the same dates) on the fly?
-
- Site Admin
- Posts: 14730
- Joined: Mon Jun 09, 2003 4:00 am
- Location: Banyoles, Catalonia
- Contact:
Hi CAC,
You can set the date value to be the XValue in the series and set the bottom axis as DateTime as told in Tutorial 4 - Axis Control. You'll find the tutorials at TeeChart's program group.
You can set the date value to be the XValue in the series and set the bottom axis as DateTime as told in Tutorial 4 - Axis Control. You'll find the tutorials at TeeChart's program group.
Best Regards,
Narcís Calvet / Development & Support Steema Software Avinguda Montilivi 33, 17003 Girona, Catalonia Tel: 34 972 218 797 http://www.steema.com |
Instructions - How to post in this forum |
I understand how to set the date value as the x-axis. What I need to do is figure out how TeeChart understands when it encounters a new well in my long list wells and then how it undertsands the new dates associated with those new wells. For example, how do I get 2 series (MW-01 and MW-02) out of this:
MW-01 10/23/55 567.89
MW-01 1/1/56 578.90
MW-01 5/4/56 578.40
MW-02 11/21/55 500.78
MW-02 1/15/56 502.34
MW-02 4/5/67 504.25
MW-01 10/23/55 567.89
MW-01 1/1/56 578.90
MW-01 5/4/56 578.40
MW-02 11/21/55 500.78
MW-02 1/15/56 502.34
MW-02 4/5/67 504.25
Hi.
I think you'll have to use the manual approach i.e. go through all values in table and create the necessary series and then populate them with values by using AddXY method. Pseudo code:
the SeriesExists function looks through all series in Chart.Series array and compares well value (string) with Chart.Series[index].Title. If match is found it returns Series[index], otherwise it returns nil. The CreateNewSeries founction adds new series to Chart and set it's (Series!) title to well value.
I know, it's not one-line-code, but it works and it gives you full control over the process.
I think you'll have to use the manual approach i.e. go through all values in table and create the necessary series and then populate them with values by using AddXY method. Pseudo code:
Code: Select all
var ser: TChartSeries;
With Table do
begin
First;
While Not(Eof) do
begin
// returns ser if ser.Title == Well value, otherwise nil
ser = SeriesExists(ColumnByName('Well').AsString);
if Not Assigned(ser) then ser := CreateNewSeries(ColumnByName('Well').AsString);
// finally, add point to correct series
ser.AddXY(ColumnByName('Data').AsString, ColumnByName('Data').AsDouble);
Next;
end;
end;
I know, it's not one-line-code, but it works and it gives you full control over the process.
Marjan Slatinek,
http://www.steema.com
http://www.steema.com
Hi.
SeriesExists function has to be coded (doesn't exists). The idea is to cycle through all chart series and if there is a match (series title is equal to "Well" column name, return series, otherwise return nil.). It's not too complicated at all:
The same (you have to code it yourself) goes for CreateNewSeries function:
SeriesExists function has to be coded (doesn't exists). The idea is to cycle through all chart series and if there is a match (series title is equal to "Well" column name, return series, otherwise return nil.). It's not too complicated at all:
Code: Select all
function SeriesExists(aChart: TCustomChart; ColName: String):TChartSeries;
begin
result := nil;
for i := 0 to aChart.SeriesCount-1 do
if aChart.Series[i].Title = ColName then
begin
result := aChart.Series[i];
break;
end;
end;
Code: Select all
function CreateNewSeries(aChart: TCustomChart; ColName: String): TChartSeries;
begin
result := TLineSeries.Create(aChart);
result.Title := ColName;
result.ParentChart := aChart;
end;
Marjan Slatinek,
http://www.steema.com
http://www.steema.com