Environment - Delphi 7 and TChart 7.07 working against an Oracle database (using DOA components).
I have a fairly standard bar chart and my user wants to double-click on a bar and then navigate to a new screen that displays the detail data. What I need to be able to do on the Double-click event is determine the text of the X-Axis (the bars go up the Y-Axis and the points go along the X-Axis) under the bar they double-clicked on. I can use that value to then get the detail data and show this data (thats easy). I can't quite figure out is how to get the value of the X-Axis label. Is there an easy way to do this? Also, is there any built in "Drill-down" capability in this version.
Thanks
Richard Anderson
Drill-down help and examples
-
- Site Admin
- Posts: 14730
- Joined: Mon Jun 09, 2003 4:00 am
- Location: Banyoles, Catalonia
- Contact:
Hi Richard,
Yes, labels can be retrieved like this:
Regarding built in drill-down, there's MarkTips tool, another option is interpolating series like shown here or using hints over the line like this:
Yes, labels can be retrieved like this:
Code: Select all
procedure TForm1.Series1DblClick(Sender: TChartSeries; ValueIndex: Integer;
Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
begin
Chart1.Title.Text[0]:=Sender.Labels[ValueIndex];
end;
Code: Select all
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, TeEngine, Series, ExtCtrls, TeeProcs, Chart;
type
TForm1 = class(TForm)
Chart1: TChart;
Series1: TLineSeries;
procedure FormCreate(Sender: TObject);
procedure Chart1MouseMove(Sender: TObject; Shift: TShiftState; X,
Y: Integer);
private
{ Private declarations }
OnSeriesPoint : Boolean;
OnLegendPoint : Boolean;
tmpL2 : Integer;
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.FormCreate(Sender: TObject);
begin
Series1.FillSampleValues(10);
Chart1.View3D := False;
end;
procedure TForm1.Chart1MouseMove(Sender: TObject; Shift: TShiftState; X,
Y: Integer);
var tmp, tmpL : Integer;
begin
With Chart1 do
begin
If (Series1.Clicked(X, Y) <> -1) And (OnSeriesPoint = False) Then
begin
Canvas.Brush.Style := bsSolid;
Canvas.Pen.Color := clBlack;
Canvas.Brush.Color := clWhite;
canvas.TextOut(x+10,y,FormatFloat('#.00',Series1.XScreenToValue(x))+','+FormatFloat('#.00',Series1.YScreenToValue(y)));
OnSeriesPoint := True;
End;
//Repaint Chart to clear Textoutputted Mark
If (Series1.Clicked(X, Y) = -1) And (OnSeriesPoint = True) Then
begin
OnSeriesPoint := False;
Repaint;
End;
tmpL := Chart1.Legend.Clicked(X, Y);
If (tmpL <> -1) And ((tmpL <> tmpL2) Or (OnLegendPoint = False)) Then
begin
Repaint;
Canvas.Brush.Color := Series1.LegendItemColor(tmpL);
Canvas.Rectangle( X, Y, X + 20, Y + 20);
Canvas.Brush.Color := clWhite;
canvas.TextOut(x+7,y+7,FormatFloat('#.00',Series1.XValues.Items[Series1.LegendToValueIndex(tmpl)]));
tmpL2 := tmpL;
OnLegendPoint := True;
End;
If (Legend.Clicked(X, Y) = -1) And (OnLegendPoint = True) Then
begin
OnLegendPoint := False;
Repaint;
End;
End;
end;
end.
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 |