SciChart® the market leader in Fast WPF Charts, WPF 3D Charts, and now iOS Charting & Android Chart Components

Welcome to the SciChart Community Forums!

Please use the forums below to ask questions about SciChart. Take a moment to read our Question asking guidelines on how to ask a good question and our support policy. We also have a tag=SciChart on Stackoverflow.com where you can earn rep for your questions!

Please note: SciChart team will only answer questions from customers with active support subscriptions. Expired support questions will be ignored. If your support status shows incorrectly, contact us and we will be glad to help.

Answered
1
0

What would be the easiest way of changing the zero line on a mountain chart?

I am plotting seabed elevations along a particular route. These values are always negative. Rather than shading the area above the dataseries (up to a value of 0) I would like to the shading to happen below the series (up to a specified negative value, which I would set to a depth well below my deepest point).

I have considered:
+ shifting my data points and working with a custom label formatter
+ swapping chart surface background and mountain area colours, but then the gridlines appear on the wrong side of the series

I noticed from the documentation that there is a zeroCoord parameter in the protected RenderMountainArea method, but I’m not sure how to best override it…

Any suggestions?

  • You must to post comments
Best Answer
1
0

Hi there,

Please, try overriding the InternalDraw(..) method in this way:

        protected override void InternalDraw(IRenderContext2D renderContext, IRenderPassData renderPassData)
        {   
            var theDeepestPoint = -100;

            var zeroCoord = (float)(CurrentRenderPassData.IsVerticalChart
                                  ? Math.Min(Width + 1, CurrentRenderPassData.YCoordinateCalculator.GetCoordinate(theDeepestPoint))
                                  : Math.Min(Height + 1, CurrentRenderPassData.YCoordinateCalculator.GetCoordinate(theDeepestPoint)));

            var gradientRotationAngle = GetChartRotationAngle(renderPassData);

            using (var areaBrush = renderContext.CreateBrush(AreaBrush, Opacity))
            using (var linePen = renderContext.CreatePen(SeriesColor, AntiAliasing, StrokeThickness, Opacity))
            {
                RenderMountainArea(renderContext, linePen, areaBrush, PointMarker,
                                    zeroCoord, gradientRotationAngle);
            }
        }

Does it do the trick?

UPDATED FOR SCICHART 3.0:

We’ve now added the property ZeroLineY to FastMountainRenderableSeries, so you can change this yourself. It also works for Column Series

/// 
/// Gets or sets the value which determines the zero line in Y direction.
/// Used to set the bottom of a column, or the zero line in a mountain
/// 
public double ZeroLineY
{
    get { return (double)GetValue(ZeroLineYProperty); }
    set { SetValue(ZeroLineYProperty, value); }
}

Best regards,
Yuriy

  • Jelle Muylle
    Dear Yuriy, that does indeed work! Thanks, Jelle
  • You must to post comments
Showing 1 result
Your Answer

Please first to submit.