根据这个例子,在chart3D1_MouseMove方法中修改ChartLabels[0].Text就可以达到你要的效果。
- this.chart3D1.ChartLabels[0].Text = String.Format("X={0}; Y={1}; Z={2}", x, y, z);
复制代码
- private void chart3D1_MouseMove(object sender, System.Windows.Forms.MouseEventArgs e)
- {
- if( !bCapture)
- return;
-
- lblMouse.Text = String.Format( "X={0}; Y={1}", e.X, e.Y);
- float _x=0, _y=0, _z=0;
- if( chart3D1.ChartGroups[0].ChartData.CoordToDataCoord( e.X, e.Y, ref _x, ref _y, ref _z))
- {
- if( _x!=x || _y!=y || _z!=z)
- {
- x = _x; y = _y; z = _z;
- lblDataCoord.Text = String.Format( "X={0}; Y={1}; Z={2}", x, y, z );
- this.chart3D1.ChartLabels[0].Text = String.Format("X={0}; Y={1}; Z={2}", x, y, z);
- if( rbValueLabels.Checked)
- toggleValueLabels( true);
- }
- else
- return;
- }
- else
- {
- //lblDataCoord.Text = " Not in data range";
- }
- int row = 0, col = 0;
- if( chart3D1.ChartGroups[0].ChartData.CoordToDataIndex( e.X, e.Y, ref col, ref row))
- {
- lblDataIndex.Text = String.Format( "Col={0}; Row={1}", col, row);
- chart3D1.ChartLabels[0].AttachMethodData.Column = col;
- chart3D1.ChartLabels[0].AttachMethodData.Row = row;
- if( chart3D1.ChartGroups[0].ChartType == Chart3DTypeEnum.Bar)
- {
- if( old_col!=-1 && old_row!=-1)
- chart3D1.ChartGroups[0].Bar.SetBarColor( old_col, old_row, Color.White);
- chart3D1.ChartGroups[0].Bar.SetBarColor( col, row, Color.Red);
- }
- old_row = row;
- old_col = col;
- btnSetData.Enabled = true;
- }
- else
- {
- //lblDataIndex.Text = " Not in data range";
- }
- }
复制代码
|