teechartでエラーシリーズのy座標を読み取る方法は?カーソルがy軸上を移動するときのy軸の上下の座標が必要です。
1222 次
2 に答える
2
TeeChartマウスイベント(例:OnMouseMove)とシリーズのClickedメソッドを使用して、マウスの下にあるポイントを確認し、次の例のように対応する値を取得する必要があります。
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
InitializeChart();
}
private void InitializeChart()
{
tChart1.Aspect.View3D = false;
tChart1.Series.Add(new Steema.TeeChart.Styles.Error()).FillSampleValues();
tChart1.MouseMove += new MouseEventHandler(tChart1_MouseMove);
}
void tChart1_MouseMove(object sender, MouseEventArgs e)
{
Steema.TeeChart.Styles.Error error1 = (Steema.TeeChart.Styles.Error)tChart1[0];
int index = error1.Clicked(e.X, e.Y);
string tmp = "";
if (index != -1)
{
double y = error1.YValues[index];
double error = error1.ErrorValues[index];
double top = y + error;
double bottom = y - error;
tmp = top.ToString("#.##") + " - " + bottom.ToString("#.##");
}
else
{
tmp = "";
}
this.Text = tmp;
}
}
CursorToolを使用する場合、CursorToolの軸値を提供するe.XValue引数とe.YValue引数があり、MouseMove eXおよびeY引数と同等のexおよびeyがあるため、そのイベントと同じように実行できます。簡単な例:
public Form1()
{
InitializeComponent();
InitializeChart();
}
private void InitializeChart()
{
tChart1.Aspect.View3D = false;
tChart1.Series.Add(new Steema.TeeChart.Styles.Error()).FillSampleValues();
//tChart1.MouseMove += new MouseEventHandler(tChart1_MouseMove);
Steema.TeeChart.Tools.CursorTool cursor1 = new Steema.TeeChart.Tools.CursorTool(tChart1.Chart);
cursor1.Series = tChart1[0];
cursor1.FollowMouse = true;
cursor1.Change += new Steema.TeeChart.Tools.CursorChangeEventHandler(cursor1_Change);
}
void cursor1_Change(object sender, Steema.TeeChart.Tools.CursorChangeEventArgs e)
{
Steema.TeeChart.Styles.Error error1 = (Steema.TeeChart.Styles.Error)tChart1[0];
int index = error1.Clicked(e.x, e.y);
string tmp = "";
if (index != -1)
{
double y = error1.YValues[index];
double error = error1.ErrorValues[index];
double top = y + error;
double bottom = y - error;
tmp = "Error top: " + top.ToString("#.##") +
" Error bottom: " + bottom.ToString("#.##") +
" Cursor pos.: " + e.XValue.ToString("#.##") + "/" + e.YValue.ToString("#.##");
}
else
{
tmp = "";
}
this.Text = tmp;
}
于 2012-03-14T08:29:21.420 に答える
-3
私はteechartに精通していませんが、cursor.moveイベントがあると確信しています。そうでない場合は、作成できます。次に、そのイベントを変更して、cursor.positionをキャッチします。
CursorMove(object sender, args e)
{
this.lowerTextBox.value = cursor.postion;
}
于 2012-03-13T16:18:52.987 に答える