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

chart with flipped min-max values for y axis is cut off #534

Closed
yuvii opened this issue Sep 2, 2014 · 9 comments
Closed

chart with flipped min-max values for y axis is cut off #534

yuvii opened this issue Sep 2, 2014 · 9 comments
Labels
C-feature-request Category: A feature request or an enhancement R-needs-docs Request for changes: The PR needs documentation resolved maybe

Comments

@yuvii
Copy link
Contributor

yuvii commented Sep 2, 2014

If you set up the y axis min and max values to be flipped (i.e., min is higher than max, a common need if, for example, you're showing data where less is better), the chart is calculated wrong and the graph is cut off. See demo

var chart = c3.generate({
    data: {
        columns: [
            ['data1', 100, 200, 150, 300, 200],
            ['data2', 400, 500, 250, 700, 300], ]
    },
    axis: {
        y: {
            min: 700,
            max: 100
        }
    }
});

I can achieve this with some trickery (using negative values and formatting), but I'm considering that a hack

@masayuki0812
Copy link
Member

Hi, I don't think this feature is essential and it's a little bit tricky as a chart. So, I'd like to pass at this time.

@geonux
Copy link

geonux commented Nov 18, 2014

I need the same functionnality; but for the bar chart representation. Indeed, it is a common representation to display the rainfall with other weather parameters.

jqChart provides the "inverted" parameter as shown in this example : http://jsfiddle.net/FSEQP/

I got the same thing with NVD3 reversing the "yDomain" (cf. http://stackoverflow.com/questions/21137947/nvd3-set-scale-from-big-to-small)

Do you know a way to achieve a same functionnality with C3.JS without touching the incomming data as proposed by 'yuvii' ?

@geonux
Copy link

geonux commented Nov 18, 2014

It's maybe possible to inject this functionnality with d3 native functions like this : http://stackoverflow.com/questions/15011256/d3-bar-chart-is-upside-down

But i dont know how to do that with C3.js

@yuvii
Copy link
Contributor Author

yuvii commented Nov 18, 2014

@geonux for now, use my hack to achieve this

@masayuki0812 masayuki0812 added C-feature-request Category: A feature request or an enhancement and removed question labels Nov 19, 2014
@geonux
Copy link

geonux commented Nov 19, 2014

I have seen your hack, but I do not have access to the data API, so I can't invert the value.
Is it possible doiing such things in javascript with C3, on loading time ?

@masayuki0812
Copy link
Member

I added axis.y.inverted and axis.y2.inverted option by this commit, so now we can invert easily by setting this option true.
I'll release this in the next version v0.4.9 shortly. Thanks.

@masayuki0812
Copy link
Member

v0.4.9 has been released, so please let me close.

@aendra-rininsland aendra-rininsland added the R-needs-docs Request for changes: The PR needs documentation label Jan 19, 2015
@aendra-rininsland
Copy link
Member

Cool! Adding documentation tag.

@spongeboy
Copy link

Updated demo to use new inverted property. Note that the min and max need to be changed back so that min less than max.

http://jsfiddle.net/5uxf0bqc/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-feature-request Category: A feature request or an enhancement R-needs-docs Request for changes: The PR needs documentation resolved maybe
Projects
None yet
Development

No branches or pull requests

5 participants