Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
280
Draw tickmarks on X and Y axis
posted

Hi, I've two questions about drawing marks on axis:

I'm trying to draw special (small square) marks on X axis (like the sample). Is it possible? I've line and stepline graphics with only 7 values in X axis.

I also trying to draw minor ticks (not minor lines) on Y axis. Is it possible? How can I define the interval, I'm interest on draw 10 minorticks per 1 MajorGridLine.

Thanks in advanced

Parents
  • 26458
    Verified Answer
    Offline posted

    Unfortunately, the chart doesn't support tickmarks out of the box. The workaround is to handle FillSceneGraph event and draw the tickmarks there. Here's a code example how you can do this for the Y axis. You can adapt the same approach for the Y axis.

    private void ultraChart1_FillSceneGraph(object sender, FillSceneGraphEventArgs e)
    {
        if (e.Grid.Count == 0) return;

        IAdvanceAxis xAxis = (IAdvanceAxis)e.Grid["X"];
        IAdvanceAxis yAxis = (IAdvanceAxis)e.Grid["Y"];
        int min = Convert.ToInt32(xAxis.Minimum);
        int max = Convert.ToInt32(xAxis.Maximum);
        int size = 6;

        for (int i = min; i < max; i++)
        {
            Box mark = new Box(new Rectangle(
                (int)xAxis.Map(i) - size / 2,
                (int)yAxis.MapMinimum - size / 2,
                size,
                size
            ));
            mark.PE.Fill = Color.Red;
            e.SceneGraph.Add(mark);
        }
    }

Reply Children
No Data