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

[FEATURE] Add new dataset.steppedLine type #4374

Closed
bril-andrew opened this issue Jun 14, 2017 · 3 comments
Closed

[FEATURE] Add new dataset.steppedLine type #4374

bril-andrew opened this issue Jun 14, 2017 · 3 comments

Comments

@bril-andrew
Copy link

FEATURE

Add new dataset.steppedLine type to simplify migration from Google Charts.
Suggested type: middle (or any other name)
Stepped lines in Google Charts begins outside bar-columns.

My current solution jsFiddle

Current Behavior

image

Google Charts Behavior

image

@simonbrunel
Copy link
Member

@bril-andrew seems a good enhancement, can you submit a PR with docs and tests?
@ericnkatz any thoughts, since you implemented before and after?

@ericnkatz
Copy link
Contributor

ericnkatz commented Jul 6, 2017

@bril-andrew @simonbrunel looks good to me.
I used 'before' and 'after' because that's what D3 called the two styles of interpolation.

@ccreus
Copy link

ccreus commented May 16, 2018

To obtain the desired 'middle' behaviour, wouldn't it suffice a small change to function lineTo in src/helpers/helpers.canvas.js? Something like adding these 5 lines (actually 4 when putting the else and following if in the same line):

    lineTo: function(ctx, previous, target, flip) {
        if (target.steppedLine) {
+            if (target.steppedLine === 'middle') {
+                var midx = (previous.x + target.x)/2;
+                ctx.lineTo(midx, previous.y);
+                ctx.lineTo(midx, target.y);
+            } else
             if ((target.steppedLine === 'after' && !flip) || (target.steppedLine !== 'after' && flip)) {

I guessed that the flip parameter should be a no-op in the case of 'middle'. Nevertheless, I am not familiar enough with the code, so this might be breaking stuff somewhere.

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

No branches or pull requests

5 participants