TChart在底轴标签上用鼠标找到值索引 [英] TChart find valueindex with mousemove over bottom axis label

查看:171
本文介绍了TChart在底轴标签上用鼠标找到值索引的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Delphi 7和TChart版本2014Delphi7

Delphi 7 and TChart version 2014Delphi7

我有一个具有16 bar系列和16个值的3D TChart。 (一个16x16的三维条形图)

I have a 3d TChart with 16 bar series and 16 values. (a 16x16 3d bar chart)

当我将鼠标移到底部轴时,我需要知道鼠标已经结束的系列的valueindex。

When I move the mouse over the bottom axis I need to know the valueindex of the series the mouse is over.

我要隐藏(透明度= 75)所有其他值,因此只显示该索引的条。

I want to hide(transparency=75) all other values so only the bars for that index are displayed. (show only that index for all series so displayed is in effect a 1x16 chart)

如何获取鼠标结束的索引?

How can I get the index the mouse is over?

推荐答案

如果系列不在(X,Y)位置(以像素为单位),系列的Clicked(X,Y)函数返回-1。如果系列位于(X,Y)位置(以像素为单位),则返回系列下的点的索引。

The Series' Clicked(X,Y) function returns -1 if the series isn't under the (X,Y) position (in pixels). If the series is under the (X,Y) position (in pixels), it returns the index of the point under the series.

OnMouseMove事件:

Here you have a simple example using the OnMouseMove event:

uses Series;

procedure TForm1.FormCreate(Sender: TObject);
var i: Integer;
begin
  Chart1.View3D:=false;

  for i:=0 to 2 do
    Chart1.AddSeries(TBarSeries).FillSampleValues(3);
end;

procedure TForm1.Chart1MouseMove(Sender: TObject; Shift: TShiftState; X,
  Y: Integer);
var seriesIndex, valueIndex: Integer;
begin
  Caption:='No series under the mouse';

  for seriesIndex:=Chart1.SeriesCount-1 downto 0 do
  begin
    valueIndex:=Chart1[seriesIndex].Clicked(X,Y);
    if valueIndex>-1 then
      Caption:='Series under the mouse. SeriesIndex: ' + IntToStr(seriesIndex) + ', ValueIndex: ' + IntToStr(valueIndex);
  end;
end;

这篇关于TChart在底轴标签上用鼠标找到值索引的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆