Fill area between line series

Charts for WPF Forum

Posted 5 years ago by Marek Baron
Version: 13.2.0591
Avatar

Hello,

I have to draw chart with two line series, where:

- area beetwen series is filled with color

- grid lines are visible

My first try to get fill, was to draw two area series: one with data from 'upper' plot and fill color, and second with background color and data from 'lower' plot. On top of them, I've added two line series. This works, but grid lines below 'fill' area are missing, because they are obscured by area series with background color (see pic).

https://drive.google.com/file/d/0B1A54aAogwtgRGlXdHA2bGJMbkk/edit?usp=sharing

To show grid lines, I've put another instance of XYChart on top of the previous one - this way grid lines from second chart are drawn on top of the first chart (see pic).

https://drive.google.com/file/d/0B1A54aAogwtgZmZreXpaQ1FrV2M/edit?usp=sharing

This solution works, but IMHO is very ugly, so here's my questions:

1. Is there some better way to achive such effect?

2. If no, could you implement some property, to force drawing grid on top of series?

Here is link to zipped sample solution: https://drive.google.com/file/d/0B1A54aAogwtgTmllYVhKVUFpTGc/edit?usp=sharing

Comments (7)

Posted 5 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar

Hi Marek,

I think what you could probably do is have a single stacked area chart but alter the palette such that the lower series renders with a Transparent area fill and the upper renders normally. 

Note that since we'd be doing stacked mode, you would have to alter your Y axis data points for the upper series so that they are the "difference" between the real upper and lower data points.


Actipro Software Support

Posted 5 years ago by Marek Baron
Avatar

Hi,

Thank you for your answer. I've got very few data points (3 for each plot), and interpolate between them using lineKind="Spline". Data points aren't defined for the same 'x' value (user can set according to his data), and this gives me two problems:

1. I would have to calculate spline interpolation by myself to calculate 'difference'

2. AreaSerie with StackKind='Normal' doesn't work properly if datapoints aren't defined for the same 'x' value. The value from upper plot isn't added to interpolated value of lower plot, but to one of the nearby datapoints taken from lower plot.

Posted 5 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar

Hi Marek,

Yes that is true, what I suggested would work nicely, but only if the X data point values line up.

Unfortunately I'm not thinking of any other workarounds other than what you already tried.  Or switching to a line chart (without an area in between being rendered).

What is the name of this sort of chart BTW and in what scenarios is it used instead of just a regular line chart?


Actipro Software Support

Posted 5 years ago by Marek Baron
Avatar

Hi,

We have to visualise proper work parameters of a water pump - the parameters should be beetwen this two lines.

If you don't see any better solution, could you implement some property, to force drawing grid on top of series? This way I don't have to use second chart instance. Grid lines drawn on top of plots isn't a problem for me.

Posted 5 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar

Hi Marek,

I will mark down the suggestion, and will mark down the idea of a new "range area" stacking type for the charts.


Actipro Software Support

Posted 5 years ago by Marek Baron
Avatar

Hi,

can you give me some timeframe when such functionality will be available?

Posted 5 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar

Hi Marek,

I'm not sure that we would add a grid on top option since that doesn't seem like something that is normally desirable and you can already sort of work around it with what you are doing now.

The range area stacking type is what we would likely do.  We've added it to the list of suggestions for the product, but I don't have a target date at this time.  We have to prioritize it with the other suggestions for the product.  If this is a feature that you absolutely need immediately, then there is always the consulting services option that we could discuss privately if you email our support address.  When customers use consulting services, we make adding the feature our top development priority.


Actipro Software Support

The latest build of this product (v2019.1 build 0682) was released 1 month ago, which was after the last post in this thread.

Add Comment

Please log in to a validated account to post comments.