使用工具提示数据点结束时的图表数据,但我希望当我的鼠标只是在图表上时显示该值,而不一定在特定数据点上(即其他地方为空白)。我最终还希望在数据点上有一个小圆圈或正方形,但这可以稍后出现。谁能告诉我该怎么做?我将在下面包含我当前的代码。privatevoidchData_MouseMove(objectsender,MouseEventArgse){HitTestResultpos=chData.HitTest(eX,eY);如果(pos.ChartElementType==ChartElementType.DataPoint){字符串tipInfo;tipInfo="Bat1:"+ch1Array[pos.PointIndex].ToString("0.00")+Environment.NewLine+"Bat2:"+ch2Array[pos.PointIndex].ToString("0.00")+Environment.NewLine;tooltip.SetToolTip(chData,tipInfo);我想我必须更改if语句,但我不确定是什么。任何帮助是极大的赞赏!所以解决方案是不使用HitTest。相反,如果您使用PixelPositionToValue会更好。我将在下面提供代码。以上是C#学习教程:使用tooltipc#在图表任意点显示系列值分享的全部内容。如果对大家有用,需要进一步了解C#学习教程,希望大家多加关注—privatevoidchData_MouseMove(objectsender,MouseEventArgse){try{intcursorX=Convert.ToInt32(chData.ChartAreas[0].AxisX.PixelPositionToValue(e.Location.X));tipInfo="Bat1:"+ch1Array[cursorX].ToString("0.00")+Environment.NewLine+"Bat2:"+ch2Array[cursorX].ToString("0.00")+Environment.NewLine;tooltip.SetToolTip(chData,tipInfo);}catch{}}本文来自网络合集,不代表立场,如涉及侵权,请点击右侧联系管理员删除。如需转载请注明出处:
