Ternary Graph Legend and Points
Ternary Graph Legend and Points
Good evening
I am trying to create some standard geothermal ternary plots and having difficulty with some aspects. The plot I am trying to emulate is shown here. . I have also attached a test program which includes a typical data set, consisting of three numerical values, X, Y and Z, a Sample Site name and a Sample Date. I have the following questions:
1. Can I write the Sample Site on the chart besides each point, and if so how?
2. Can I write the Sample Site in the legend, and the Sample Date beside each point (or vice versa)?
3. Can I make the legend box wider to automatically fit the legend (it is not wide enoungh when the Sample Site and date are concatenated).
4. Are there tools to draw the two curved lines and text (names of regions and temperatures on the upper curved line) on the graph as in the attached image?
5. Does TeeChart provide tools to draw lines of best fit for selected points?
6. Finally, is it possible to write the square root symbol by code in TeeChart?
I look forward to any suggestions you can offer.
Thanks and regards
Errol
I am trying to create some standard geothermal ternary plots and having difficulty with some aspects. The plot I am trying to emulate is shown here. . I have also attached a test program which includes a typical data set, consisting of three numerical values, X, Y and Z, a Sample Site name and a Sample Date. I have the following questions:
1. Can I write the Sample Site on the chart besides each point, and if so how?
2. Can I write the Sample Site in the legend, and the Sample Date beside each point (or vice versa)?
3. Can I make the legend box wider to automatically fit the legend (it is not wide enoungh when the Sample Site and date are concatenated).
4. Are there tools to draw the two curved lines and text (names of regions and temperatures on the upper curved line) on the graph as in the attached image?
5. Does TeeChart provide tools to draw lines of best fit for selected points?
6. Finally, is it possible to write the square root symbol by code in TeeChart?
I look forward to any suggestions you can offer.
Thanks and regards
Errol
- Attachments
-
- TernaryGraph.zip
- (6.99 KiB) Downloaded 1159 times
Re: Ternary Graph Legend and Points
You could use the Field 6 (Sample Site) as Labels and show the Marks:
Code: Select all
procedure TTernarySeriesForm.FormCreate(Sender: TObject);
//...
with SeriesTextSource1 do
begin
HeaderLines:=1;
//...
AddField('Text',6);
//...
end;
//...
Series1.Marks.Show;
Series1.Marks.Transparent:=True;
You could load the strings from the csv and use the OnGetLegendText event to get them. Ie:
Code: Select all
var loadedText: TStrings;
procedure TTernarySeriesForm.Chart1GetLegendText(Sender: TCustomAxisPanel;
LegendStyle: TLegendStyle; Index: Integer; var LegendText: string);
var stream : TFileStream;
row: Integer;
tmpFields: TStringList;
tmp: string;
const col=6;// 4: Sample Site and Date; 5: Sample Site; 6: Sample Date
begin
if not Assigned(loadedText) then
begin
stream:=TFileStream.Create(SeriesTextSource1.FileName,fmOpenRead);
try
stream.Position:=0;
loadedText:=TStringList.Create;
loadedText.LoadFromStream(stream);
finally
stream.Free;
end;
end;
row:=Index+SeriesTextSource1.HeaderLines;
if loadedText.Count > row then
begin
tmp:=loadedText[row];
tmpFields:=TStringList.Create;
tmpFields.Clear;
tmpFields.Delimiter:=SeriesTextSource1.FieldSeparator[1];
tmpFields.StrictDelimiter:=True;
tmpFields.DelimitedText:=tmp;
if tmpFields.Count>col then
LegendText:=tmpFields[col];
end;
end;
You can use the OnGetLegendRect as follows:
Code: Select all
procedure TTernarySeriesForm.Chart1GetLegendRect(Sender: TCustomChart;
var Rect: TRect);
var tmp: String;
begin
Chart1GetLegendText(Chart1, Chart1.Legend.LegendStyle, 0, tmp);
Rect.Width:=Chart1.Canvas.TextWidth(tmp) +
Chart1.Legend.Symbol.Width + 20;
end;
I'm afraid the functions in TeeChart only support the regular perpendicular axes. These lines should be calculated and drawn manually at OnAfterDraw event. If you tell us what functions you'd like to use, we can think on the best way to use them.
As above, the Trend and the Exponential Trend functions sound as what you'd like to use but they are thought to be linked to a Line series, which uses perpendicular axes. However, you could try to inherit TLineSeries to use the axes in the Ternary plot. I haven't tried that.
Sounds exactly as this question:
viewtopic.php?f=3&t=4893
Best Regards,
Yeray Alonso Development & Support Steema Software Av. Montilivi 33, 17003 Girona, Catalonia (SP) | |
Please read our Bug Fixing Policy |
Re: Ternary Graph Legend and Points
Good afternoon
Thank you for all the suggestions - greatly appreciated. However, I am having problems reading data from a kbmMemTable into a TernarySeries. I have attached an example program where I have generated a kbmMemTable from a csv file (in the actual program it is generated from database queries). However, I cannot send the contents of the memory table to the ternary series, let alone map the memory table columns to the appropriate ternary series columns.
I would appreciate any help you can offer.
Thanks and regards
Errol
Thank you for all the suggestions - greatly appreciated. However, I am having problems reading data from a kbmMemTable into a TernarySeries. I have attached an example program where I have generated a kbmMemTable from a csv file (in the actual program it is generated from database queries). However, I cannot send the contents of the memory table to the ternary series, let alone map the memory table columns to the appropriate ternary series columns.
I would appreciate any help you can offer.
Thanks and regards
Errol
- Attachments
-
- TernaryGraph_2.zip
- (9.19 KiB) Downloaded 1092 times
Re: Ternary Graph Legend and Points
Hello,
I'm afraid I don't have experience with kbmMemTable. If you can loop the date in the table you should be able to call the AddBubbleXYZWeight method to add the date to the series. Ie:
I'm afraid I don't have experience with kbmMemTable. If you can loop the date in the table you should be able to call the AddBubbleXYZWeight method to add the date to the series. Ie:
Code: Select all
for i := 0 to 5 do
Series1.AddBubbleXYZWeight( Random(100), { X }
Random(100), { Y }
Random(100), { Z }
30-(Random(25)), { Radius }
10-(Random(10)), { Weight }
clTeeColor);
Best Regards,
Yeray Alonso Development & Support Steema Software Av. Montilivi 33, 17003 Girona, Catalonia (SP) | |
Please read our Bug Fixing Policy |
Re: Ternary Graph Legend and Points
Hello
I am sorry I did not express myself very clearly in my last post. I am attempting to load a number of ternary series from a DataSource, which happens to be a kbmMemTable. For a line series, I allocate fields to the horizontal and vertical axes using expressions such as:
What are the equivalent commands for XValues.ValueSource and YValues.ValueSource for ternary graphs - in other words, how do I assign columns to the X, Y, Z (or A, B, C) axes and also to the corresponding axis titles and legend.
Thanks and regards
Errol
I am sorry I did not express myself very clearly in my last post. I am attempting to load a number of ternary series from a DataSource, which happens to be a kbmMemTable. For a line series, I allocate fields to the horizontal and vertical axes using expressions such as:
Code: Select all
XValues.ValueSource := sDepField; // field to be plotted on the horizontal axis
YValues.ValueSource := fIndependentField; // field to be plotted on the vertical axis
DataSource := TDataset(fMultiGraphList.Objects[dID]); // each object is a kbmMemTable with data for each dataset
Thanks and regards
Errol
Re: Ternary Graph Legend and Points
Good afternoon
Further to my previous unanswered post, I would like to add the following query:
I wish to create one or many ternary series programmatically, as I want to have control over symbols and colours of each series. I have tried many different ways to create a ternary series in the code (and therefore create a ternary graph) without success. I would be very grateful if you could create a simple test program that starts with a standard chart, and which displays the results as a ternary graph when the data is specified as a Ternary Series.
I would also like to request that more of your examples in TeeNew show how to create the various charts programmatically rather than setting up the chart manually.
I look forward to hearing from you very soon.
Best regards
Errol
Further to my previous unanswered post, I would like to add the following query:
I wish to create one or many ternary series programmatically, as I want to have control over symbols and colours of each series. I have tried many different ways to create a ternary series in the code (and therefore create a ternary graph) without success. I would be very grateful if you could create a simple test program that starts with a standard chart, and which displays the results as a ternary graph when the data is specified as a Ternary Series.
I would also like to request that more of your examples in TeeNew show how to create the various charts programmatically rather than setting up the chart manually.
I look forward to hearing from you very soon.
Best regards
Errol
-
- Guru
- Posts: 1603
- Joined: Fri Nov 15, 2002 12:00 am
Re: Ternary Graph Legend and Points
Hello Errol
Of course - I hope this example will be sufficient, If not, do please let me know and I'll create another one for you.
Code: Select all
uses
VCLTee.TeeTernary;
procedure TForm1.Button1Click(Sender: TObject);
var
Ternary : TTernarySeries;
begin
Ternary:=TTernarySeries.Create(Self);
Ternary.ParentChart:=Chart1;
Ternary.FillSampleValues();
end;
Thank you for the suggestion, I have added it to our issue-tracking software with id=2167.
Best Regards,
Christopher Ireland / 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 |
Re: Ternary Graph Legend and Points
Good afternoon Christopher
Thanks for the suggestions. I have been able to create a test program, attached, that reads data from a csv file to a kbmMemTable and then assigns appropriate columns of the memory table as Value Sources for the ternary variables. I aam doing this to emulate the process in my main program. However, I have had many issues with this process as follows:
1. If some of the variables are not assigned, then TeeChart simply does not load any data. I can understand that XValues, YValues and ZValues all need to be assigned, but I have no idea why WeightValues needs to be assigned. Some sort of error message would be helpful, or some instructions on what is required. Alternatively, a test example in TeeNew that does the variable assignation, rather than relying on FillSampleValues which hides what is going on.
2. I do not understand the Weighting variable, and I cannot obtain any non-zero values for this, even if I create a field called 'Weight' and assign it to WeightValues.
3. If I assign the same field, "Conc Sum", to WeightValues.ValueSource and to RadiusValues.ValueSource, I get zero Weighting values, but at least the X, Y and Z values are correct. However, if I assign a new field 'Weight' to WeightValues.ValueSource, I still get zero Weighting values but the YValues use the values in the "Weight" column. There may be a reason for this behaviour, but I am afraid it eludes me.
4. Overall, I have spent a considerable amount of time getting to this point, because the Help is minimal to say the least. If you can point me to a listing of the various properties and methods of TTernarySeries, I would be very grateful.
Thanks and regards
Errol
Thanks for the suggestions. I have been able to create a test program, attached, that reads data from a csv file to a kbmMemTable and then assigns appropriate columns of the memory table as Value Sources for the ternary variables. I aam doing this to emulate the process in my main program. However, I have had many issues with this process as follows:
1. If some of the variables are not assigned, then TeeChart simply does not load any data. I can understand that XValues, YValues and ZValues all need to be assigned, but I have no idea why WeightValues needs to be assigned. Some sort of error message would be helpful, or some instructions on what is required. Alternatively, a test example in TeeNew that does the variable assignation, rather than relying on FillSampleValues which hides what is going on.
2. I do not understand the Weighting variable, and I cannot obtain any non-zero values for this, even if I create a field called 'Weight' and assign it to WeightValues.
3. If I assign the same field, "Conc Sum", to WeightValues.ValueSource and to RadiusValues.ValueSource, I get zero Weighting values, but at least the X, Y and Z values are correct. However, if I assign a new field 'Weight' to WeightValues.ValueSource, I still get zero Weighting values but the YValues use the values in the "Weight" column. There may be a reason for this behaviour, but I am afraid it eludes me.
4. Overall, I have spent a considerable amount of time getting to this point, because the Help is minimal to say the least. If you can point me to a listing of the various properties and methods of TTernarySeries, I would be very grateful.
Thanks and regards
Errol
- Attachments
-
- TernaryGraph.zip
- (8.71 KiB) Downloaded 1097 times
Re: Ternary Graph Legend and Points
Good evening
Further to my previous posts, I now want to move on to a multi-series ternary graph - for instance when I have samples from a number of hot springs and want to group them by springs. We have the code for this already but when I apply this to ternary series, I get nested ternary graphs - see attached test example. It looks like I will have to abandon all the existing code that we already have to group and order data in various ways, and treat ternary data as a single series and control the colours and shapes of the points in an ad-hoc manner, unless you can suggest another alternative.
To me, it seems odd that a ternary graph is so intimately associated with the series, and you cannot easily have multiple series. I feel that a it would be better to start with a triaxial ternary chart, and then be able to apply normal series to the x, y and z axes which are then transformed into percentages on the way in.
I look forward to any suggestions you might have.
Further to my previous posts, I now want to move on to a multi-series ternary graph - for instance when I have samples from a number of hot springs and want to group them by springs. We have the code for this already but when I apply this to ternary series, I get nested ternary graphs - see attached test example. It looks like I will have to abandon all the existing code that we already have to group and order data in various ways, and treat ternary data as a single series and control the colours and shapes of the points in an ad-hoc manner, unless you can suggest another alternative.
To me, it seems odd that a ternary graph is so intimately associated with the series, and you cannot easily have multiple series. I feel that a it would be better to start with a triaxial ternary chart, and then be able to apply normal series to the x, y and z axes which are then transformed into percentages on the way in.
I look forward to any suggestions you might have.
- Attachments
-
- TernaryGraph_MultiSeries.zip
- (9.69 KiB) Downloaded 1034 times
Re: Ternary Graph Legend and Points
Hello,
Excuse us for the delay here.
These projects are using components we don't have here (TkbmMemTable, TkbmCSVStreamFormat).
If you still find problems with it, could you please arrange example projects using the minimum code to reproduce them and without using 3rd party libraries?
Excuse us for the delay here.
These projects are using components we don't have here (TkbmMemTable, TkbmCSVStreamFormat).
If you still find problems with it, could you please arrange example projects using the minimum code to reproduce them and without using 3rd party libraries?
Best Regards,
Yeray Alonso Development & Support Steema Software Av. Montilivi 33, 17003 Girona, Catalonia (SP) | |
Please read our Bug Fixing Policy |