ZedGraph 标签
在 ZedGraph 中,如何一起显示每个点和 XAxis 中的文本标签?
如果我这样做,
myPane.XAxis.Type = AxisType.Text;
myPane.XAxis.Scale.TextLabels = array_of_string;
我会在 XAxis 上得到这样的标签
如果我这样做,
for (int i = 0; i < myCurve.Points.Count; i++)
{
PointPair pt = myCurve.Points[i];
// Create a text label from the Y data value
TextObj text = new TextObj(
pt.Y.ToString("f0"), pt.X, pt.Y + 0.1,
CoordType.AxisXYScale, AlignH.Left, AlignV.Center);
text.ZOrder = ZOrder.A_InFront;
text.FontSpec.Angle = 0;
myPane.GraphObjList.Add(text);
}
我会在曲线上得到标签,像这样
但如果我同时执行这两个操作,曲线上的标签就会消失。
有没有办法将这两种标签结合起来?
In ZedGraph, how do I show text labels for each point and in the XAxis
all together?
If I do
myPane.XAxis.Type = AxisType.Text;
myPane.XAxis.Scale.TextLabels = array_of_string;
I get labels on the XAxis like this
And if I do
for (int i = 0; i < myCurve.Points.Count; i++)
{
PointPair pt = myCurve.Points[i];
// Create a text label from the Y data value
TextObj text = new TextObj(
pt.Y.ToString("f0"), pt.X, pt.Y + 0.1,
CoordType.AxisXYScale, AlignH.Left, AlignV.Center);
text.ZOrder = ZOrder.A_InFront;
text.FontSpec.Angle = 0;
myPane.GraphObjList.Add(text);
}
I get labels on the curve, like this
But if I do both at the same time, labels on the curve disappear.
Is there a way to combine both kind of labels?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
在你澄清问题后我改变了我的答案。
您只需要记住正确放置标签即可:
该代码将生成以下图表:
I've changed my answer after you clarified the question.
You just have to remember to position the labels correctly:
That code will produce this graph:
如果轴类型是文本,下面的代码更容易获取点的 x 坐标;)
If the axis type is text, the code below is easier to get x-coordinates of the points ;)