Windows Forms Chart set fixed mixed labels

橙三吉。 提交于 2019-12-19 11:52:03

问题


I would like to fix my labels on my x or y axis, so they are always static. I also want to mix the labelling with numbers and strings like in shown picture. Furthermore the y axis starting with -1, how can I always start with 0?


回答1:


Setting CustomLabels is tricky as their FromPositions and ToPositions need to be set correctly or else they won't show at the right positions!

See here and here for more examples!

Here is one for your question, as I read it:

CA.AxisY.Minimum = 0;
CA.AxisY.Maximum = 4;
CA.AxisY.Interval = 1;

int old = 3;
for (int i = 0; i < 5; i++ )
{
    CustomLabel cl = new CustomLabel(i - 0.5d, i + 0.5d, 
                i < old ? i + "" : i == old ? "old" : "too old", 0, LabelMarkStyle.None);
    CA.AxisY.CustomLabels.Add(cl);
}

The Minimum and Maximum values shown can be set for all axes separately. With CustomLabels we often need to enforce the Interval ..

Using the same setup code as in your other question..



来源:https://stackoverflow.com/questions/33556991/windows-forms-chart-set-fixed-mixed-labels

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!