TeeChart .NETのエラーシリーズのX座標とY座標を読み出す方法
質問
Teechartの誤差シリーズのY座標を読み出す方法カーソルが移動すると、Y軸の上下の座標が必要です。
解決
この例のように、マウスの下にあるかを知るためにTeeChartマウスイベント(例:OnMouseMove)とシリーズ 'クリックされたメソッドを使用する必要があります。
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を使用する場合は、MouseMove EXとEYの引数と同じであるCursorToolとEyと同じであるE.xValueとE.YValue引数があります。イベント、簡単な例:
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;
}
. 他のヒント
私はTeeChartに慣れていませんが、Cursor.Moveイベントがあると確信しています。 それからcursorをキャッチするためにそのイベントを修正します.position so
CursorMove(object sender, args e)
{
this.lowerTextBox.value = cursor.postion;
}
. 所属していません StackOverflow