Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement fill on stacked lines and other fixes #94

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Implement fill on stacked lines and other fixes #94

wants to merge 1 commit into from

Conversation

orgrim
Copy link

@orgrim orgrim commented May 23, 2012

Hello,

Having this feature is not easy, so I came up with this patch that work for me.

The patch includes the following modifications in the plot method of the lines type :

  • An attempt to implement the fill on staked lines. The current limitations are :
    • Only works if the x values are the same for all the series
    • When a lower line have a hole not present in the upper line, we see some white in the bottom corners of the hole (see the example, the stack lacks the info needed to fill those blanks)
  • Fix the stack increment for empty values where data[i][1] is not null
  • Restart the path when encountering holes even if fill is false
  • Issue the moveTo() when updating the start value
  • Do not skip the points outside the canvas (the canvas clips the shapes by itself) to avoid glitches in the fill

Example: http://jsfiddle.net/6TqT4/6/

Nicolas

@cesutherland
Copy link
Member

Thanks for the feature! Will it be difficult to make this fill down to the previously filled series? In the fiddle above, filling those white triangles...

I'll have to double check a few other tests and run a performance profile though, and then should be good to merge in.

@orgrim
Copy link
Author

orgrim commented May 28, 2012

Hello,

Another approach would be to keep the closing shape to the x axis combined with the use of globalCompositeOperation = source-out to remove the overlapping fill. This would allow to avoid those empty triangles and gliches when we have curves. See https://developer.mozilla.org/samples/canvas-tutorial/6_1_canvas_composite.html

And it looks simpler

Nicolas

@jjmontesl
Copy link

For the record, I've tested this and seems to be an improvement over the current master.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants