Home > Net >  C # winfrom program Chart control problem.
C # winfrom program Chart control problem.

Time:11-21

I want to be a curve, click on the node of the curve shows that the X, Y data for it, but to chart1 binding data, click on the node Y can display the correct data, but the data is always 0 X, don't know why, who can give an explanation of the great god,
Dt dataTable detected data from database tables, there are two column values, sendTime for time,
value1 to dataThe bound data source
Chart1. The DataSource=dt;
Chart1. Series [0]. Points. DataBind (dt) DefaultView, "sendtime", "value1", "");
Chart1. DataBind ();



If, get data node y is normal, x is always zero.

CodePudding user response:

What is your X coordinate unit? I think if you bind sendtime format and chart support is not the same

CodePudding user response:

reference 1/f, ning if if reply:
what is your X coordinate unit? I think if you bind sendtime format and chart support different ah

Chart1. Series [0]. XValueType=ChartValueType. Auto;

CodePudding user response:


There is something wrong with the display mode!

Look at my
"Series2" Chart1. Series [] ToolTip="Day: # VALX \ \ NPCS: # VAL".//\ \ n is a newline

CodePudding user response:

Checked again yesterday, not display problem, after binding the data points in the value of x is 0, I don't know why!

CodePudding user response:

reference ManBOyyy reply: 3/f

There is something wrong with the display mode!

Look at my
"Series2" Chart1. Series [] ToolTip="Day: # VALX \ \ NPCS: # VAL".//\ \ n is a newline


You this is direct hovering show, I want to do is a mouse click on the node, according to
Private void chart1_MouseClick (object sender, MouseEventArgs e)
{
HitTestResult hit=chart1. HitTest (e.X, e.Y);
If (hit Series!=null)
{
Var xValue=https://bbs.csdn.net/topics/hit.Series.Points [hit PointIndex] xValue;//shown here is always 0
Var yValue=https://bbs.csdn.net/topics/hit.Series.Points [hit PointIndex] YValues. The First ();
MessageBox. Show (xValue + ";" + yValue);
}
}

CodePudding user response:

reference 5 building rockets caterpillar reply:
Quote: refer to the third floor ManBOyyy response:


There is something wrong with the display mode!

Look at my
"Series2" Chart1. Series [] ToolTip="Day: # VALX \ \ NPCS: # VAL".//\ \ n is a newline


You this is direct hovering show, I want to do is a mouse click on the node, according to
Private void chart1_MouseClick (object sender, MouseEventArgs e)
{
HitTestResult hit=chart1. HitTest (e.X, e.Y);
If (hit Series!=null)
{
Var xValue=https://bbs.csdn.net/topics/hit.Series.Points [hit PointIndex] xValue;//shown here is always 0
Var yValue=https://bbs.csdn.net/topics/hit.Series.Points [hit PointIndex] YValues. The First ();
MessageBox. Show (xValue + ";" + yValue);
}
}


This line not line
Private void ChartMain_MouseMove (object sender, MouseEventArgs e)
{
Var area=chartMain. ChartAreas [0];
Double xValue=https://bbs.csdn.net/topics/area.AxisX.PixelPositionToValue (e.X);
Double yValue=https://bbs.csdn.net/topics/area.AxisY.PixelPositionToValue (e.Y);

}
  •  Tags:  
  • C#
  • Related