Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Bar charts y axis zero value #5

Closed
planetmike opened this Issue · 6 comments

5 participants

@planetmike

Looking at the bar chart examples, the y-axis scale is wrong. The base should be zero, to show that cheese and pepperoni are scaled appropriately. On bar charts, this is a subtle error that can be misleading.

@paularmstrong

This is actually a feature, as designed. Any changes will be made as a feature enhancement. The original use-case for xCharts was to be able to show the difference between series, not the difference from a superficial value of zero.

I imagine this won't be much work to support xMin, xMax, yMin, and yMax as both data properties and xChart settings.

@paularmstrong

For some clarification: let's look at an example

The following 2 charts have identical data;

[
  {
    "x": "A",
    "y": 78000
  },
  {
    "x": "B",
    "y": 95000
  }
]

example

The first chart shows xCharts' default behavior, which is to help show the difference between the two values, 17,000 is quite a large gap. The second shows the difference from zero for each ordinal value, making the difference look like it is somewhat less than it really is.

@planetmike

Thanks for making those charts. I disagree though. In this example, the 17,000 absolute value is not that different. What if "A" was 1,000 and "B" was 18,000. That is a big difference, and would be easy to see with a base of zero. What if "A" were 1,000,000, and "B" were 1,017,000. In that case, the difference of 17,000 is negligible and your first chart would be deceptive. That's why bar charts almost always show a zero value on their y axis.

If the values have a huge scale, such as the 1,000,000 example I gave, then the y-axis may be truncated through a squiggly line of some sort, between the zero and the 950,000 value or so.

I love this charting library, and am thinking of a few ways I could use it. Thank you for taking the time to talk with me.

@paularmstrong paularmstrong was assigned
@p0wl

I agree with @planetmike. It should be possible to enable and disable zero as the default y-axis.

Another possibility:
y-axis could be set to zero, min, max, or any number/data. Same applies to x-axis.

Great library btw!

@ajanini

I can't get yMin to work correctly when set to 0.
Here's the relevant part of my code (based on the example from the site):

            var data = {
                "xScale": "ordinal",
                "yScale": "linear",
                "yMin": 0,
                "type": "bar",
                "main": [
                    {
                        "className": ".pizza",
                        "data": [
                            {
                                "x": "Diretoria",
                                "y": totalDiretoria
                            },
                            {
                                "x": "Solicitante",
                                "y": totalSolicitante
                            },
                            {
                                "x": "Desenvolvimento",
                                "y": totalDesenvolvimento
                            }
                        ]
                    }
                ]
            }

Captura de Tela

If I set yMin to some other value, like -1, it works, however:

Captura de Tela 1

What am I doing wrong?

@fission6

Not sure if related but I get a weird floating issue when a bar chart y value is 0

screen shot 2013-06-26 at 1 29 06 pm

This happens with ordinal Y scale

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.