chart1.Series[0].XValueType = ChartValueType.String;
...
//按顺序添加了points数据(string类型,double类型)
下面我要根据条件添加标注annotation:
for(int i = 0; i < rowCount; i++)
{
annotation = new TextAnnotation();
annotation.AxisX = chart1.ChartAreas[0].AxisX;
annotation.AxisY = chart1.ChartAreas[0].AxisY;
annotation.AnchorX = listInput[i].name;//这是一个字符串,与X轴的显示数据对应
annotation.AnchorY = listInput[i].volumn;//double类型
annotation.Text = "B";//需要标注的文本
annotation.Font = new Font("Arial", 6, FontStyle.Bold);
annotation.ForeColor = Color.Red;
chart1.Annotations.Add(annotation);//添加标注
}
为什么总是提示AnchorX应为double类型?不是已经设置了为string类型吗?
请各位大侠指点,X轴为string类型时,如何检索定位,谢谢!
已解决,方案如下,希望对大家有帮助:
将X值设为数据行的索引序号,设置每个point的AxisLabel属性为实际需要显示的文本值,结果就会只显示AxisLabel不显示数值序号;
但进行XY坐标单点定位时仍然需要使用X数值(不使用AxisLabel)。
annotation.AnchorX
这个属性必须是double
你试试看
annotation.Text
annotation.Text是需要标注的文本,好像标注位置需要用annotation.AnchorX、annotation.AnchorY定位。
如果是这样的图,数据点很多的话,如何定位到某一个特定的点?