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

Origin is not correctly positioned #521

Closed
MarcusJT opened this issue Aug 28, 2014 · 4 comments
Closed

Origin is not correctly positioned #521

MarcusJT opened this issue Aug 28, 2014 · 4 comments
Labels

Comments

@MarcusJT
Copy link

While viewing http://c3js.org/ and http://c3js.org/gettingstarted.html I've noticed that the axis origins (i.e. zero points) are incorrectly positioned - they should surely be at the actual crossing of the axes by default, i.e. unless otherwise specified?

example

@santazhang
Copy link
Contributor

By setting axis padding and chart range, you achieve this.

var chart = c3.generate({
    data: {
        columns: [
            ['data1', 30, 200, 100, 400, 150, 250],
            ['data2', 50, 20, 10, 40, 15, 25]
        ],
        axes: {
            data1: 'y',
            data2: 'y2'
        }
    },
    axis: {
        y: {
            padding: {bottom: 0},
            min: 0
        },
        x: {
            padding: {left: 0},
            min: 0
        }
    }
});

JS Fiddle: http://jsfiddle.net/santazhang/gswhaLu0/1/

@MarcusJT
Copy link
Author

Thanks, that partially solves the problem, but...

  • In the JSFiddle you so kindly provided the first data point appears partially obscured by the Y axis, which isn't right - it should be drawn on top, not underneath and clipped
  • When there IS padding (as in my example image) the two lines cross and go over each other, which doesn't make any sense as it is not the origin... so how can the axes be configured so that the lines stop at the point they touch instead of carrying on over each other?
  • C3 defaults are very strange/unusual settings, resulting in unorthodox graphs which have features that don't match common / real-world graphs... why? Why not use the traditional settings I'm asking about, which is what most people will expect?

@masayuki0812
Copy link
Member

Hi,

  • c3 does not fix the origin as 0 because the origin is not always 0. I mean if the range of data is 100 to 500, we would want to focus on the range something like 80 to 520.
  • As you say, it seems natural, but now it's difficult to display the first data point as you write because of the spec of SVG and the way of implementation of c3. However, I think it's acceptable and a kind of trade off. Do you have any idea to fix this?
  • Sorry I'm not sure what you mean, but if you mean the tick on the bottom and the top of axis, it's d3 way. However, it's possible to hide by using axis.x.tick.outer = false and axis.y.tick.outer = false if you want.
  • As you say, the default settings is important. I'll update according to the requests if needed.

@masayuki0812
Copy link
Member

Please let me close.

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

No branches or pull requests

3 participants