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
1300
Line at zero for a composite chart
posted

Hi I woul like to add a horizontale line at zero on the x axis on my composite chart.

 

I tried this :

            IAdvanceAxis x = (IAdvanceAxis)e.Grid["X"];
            IAdvanceAxis y = (IAdvanceAxis)e.Grid["Y"];
            if (x != null)
            {
                int target = 0;
                int yTarget = (int)y.Map(target);
                int xStart = (int)x.Map(0);
                int xEnd = (int)x.Map(5);
                Line line = new Line(new Point(xStart, yTarget), new Point(xEnd, yTarget));
                line.PE.Stroke = Color.Red;
                line.PE.StrokeWidth = 3;
                e.SceneGraph.Add(line);
            }

 

But nothing appears.

Any idea ?

Thanks

  • 53790
    Verified Answer
    posted

    Hi,

    Generally your line is there, but it is not visible, because your Axis X is over the line. To solve this task we have two options.

    Option 1: We could used Range properties. For example:

    - RangeType = Custom;

    - RangeMin = - 50;

    -RangeMax = 100

    By this way we could change the range of your Y axis and when your chart line has zero values, they will be visible.

    Option 2:

    We could used LineAppearance properties and we could change the Thickness of the line. For example:

    LineAppearance la = new LineAppearance(ultraChart1);

    la.IconAppearance.Icon = SymbolIcon.Circle;

    la.IconAppearance.IconSize = SymbolIconSize.Large;

    la.LineStyle.EndStyle = LineCapStyle.DiamondAnchor;

    la.Thickness = 8;

    LineChartAppearance lca = new LineChartAppearance();

    lca.LineAppearances.Add(la);

    myColumnLayer.ChartTypeAppearance = lca;

    I made small smple for you using my second approach. Could you please take a look at the attached sample for more details. Let me know if you have  any questions.

    Regards

    CompositeLineChart_Year_3.zip