Page 1 of 1

How to get xyz-Values from contour plots?

Posted: Mon Sep 29, 2014 4:14 pm
by 16669864
Hello together,

my program (c++ with teechart Activex) produces a contour plot from a huge xyz-array. I try to show the user these values if he click on the chart at runtime.

For 2d-series I do this with the event OnClickSeries(...), but it does not work with contour plots.

Could anyone explain me, how I could do this?

Regards
Raimund

Re: How to get xyz-Values from contour plots?

Posted: Tue Sep 30, 2014 8:37 am
by yeray
Hi Raimund,

I've made a simple example in VB6 to check this:

Code: Select all

Private Sub Form_Load() 
  TChart1.Header.Text.Clear
  TChart1.Header.Text.Add TChart1.Version
  TChart1.Aspect.View3D = False

  TChart1.AddSeries scContour
  TChart1.Series(0).FillSampleValues
  TChart1.Series(0).Marks.Visible = True
  TChart1.Series(0).Marks.Transparent = True
  TChart1.Series(0).asContour.Filled = False
End Sub

Private Sub TChart1_OnClickSeries(ByVal SeriesIndex As Long, ByVal ValueIndex As Long, ByVal Button As TeeChart.EMouseButton, ByVal Shift As TeeChart.EShiftState, ByVal X As Long, ByVal Y As Long)
  If (SeriesIndex >= 0) And (TChart1.SeriesCount > 0) And (TChart1.Series(SeriesIndex).Count > 0) And (ValueIndex >= 0) Then
    Caption = Format$(TChart1.Series(SeriesIndex).asContour.Levels.Items(ValueIndex).UpToValue, "#0.###")
  End If
End Sub
ContourClick.png
ContourClick.png (42.15 KiB) Viewed 11004 times
And I've also made the same example in Delphi using TeeChart VCL (note TeeChart ActiveX is a wrapper from the VCL version):

Code: Select all

uses TeeSurfa;

var Chart1: TChart;

procedure TForm1.FormCreate(Sender: TObject);
begin
  Chart1:=TChart.Create(Self);
  Chart1.Parent:=Self;
  Chart1.Align:=alClient;

  Chart1.View3D:=false;

  with Chart1.AddSeries(TContourSeries) as TContourSeries do
  begin
    FillSampleValues;
    Marks.Visible:=true;
    OnClick:=ContourOnClick;
  end;
end;

procedure TForm1.ContourOnClick(Sender:TChartSeries; ValueIndex:Integer; Button:TMouseButton; Shift: TShiftState; X, Y: Integer);
begin
  if (Sender<>nil) And (Sender.Count > 0) And (ValueIndex >= 0) Then
    Caption := 'Index: ' + IntToStr(ValueIndex) + ', Level: ' + FormatFloat( '#0.###', (Sender as TContourSeries).Levels.Items[ValueIndex].UpToValue);
end;
I see the event is fired when you click on the levels, not when you click on the filled area.
How would you expect it to work?

Re: How to get xyz-Values from contour plots?

Posted: Tue Sep 30, 2014 2:01 pm
by 16669864
Hi Yeray,

OnClickSeries(...) only works, if I click on the countour line. My contour plot ist filed without drawn contour lines. I need the values also if the user clicks between two contour lines.

Regards
Raimund

Re: How to get xyz-Values from contour plots?

Posted: Tue Sep 30, 2014 3:17 pm
by yeray
Hi Raimund,

Take a look at the discussion some time ago took place here.