cqtrq 2016-06-19 13:10 采纳率: 100%
浏览 1938
已采纳

chart的X轴是string类型,添加annotation时如何定位?

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类型时,如何检索定位,谢谢!

  • 写回答

3条回答 默认 最新

  • cqtrq 2016-06-25 03:14
    关注

    已解决,方案如下,希望对大家有帮助:
    将X值设为数据行的索引序号,设置每个point的AxisLabel属性为实际需要显示的文本值,结果就会只显示AxisLabel不显示数值序号;
    但进行XY坐标单点定位时仍然需要使用X数值(不使用AxisLabel)。

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?