1

Starting form the example on Grouped / Stacked Multi-Bar I draw this graph using nvd3.js: Grouped bars

When I click on the Stacked control, the second series is not drawn from the start of the axis: Stacked bars

I dont understand why is that. Here is a jsfiddle example of my code: http://jsfiddle.net/58rw7/1/

My data looks like this:

[
    {
        "key": "a - BAR_FM - kWh - F1",
        "values": [
            {
                "x": "0_0",
                "y": 50,
                "label": "1/1/2014"
            },
            {
                "x": "0_1",
                "y": 108,
                "label": "2/1/2014"
            },
            {
                "x": "0_2",
                "y": 109,
                "label": "3/1/2014"
            }
        ]
    },
    {
        "key": "a - CONDIZIONAMENTO_IDRICO - kWh - F1",
        "values": [
            {
                "x": "1_0",
                "y": 186,
                "label": "1/1/2014"
            },
            {
                "x": "1_1",
                "y": 186,
                "label": "2/1/2014"
            },
            {
                "x": "1_2",
                "y": 184,
                "label": "3/1/2014"
            }
        ]
    }
]

Why the second series is not drawn from the start of the axis? How can I do that?

user1498339
  • 629
  • 4
  • 9
  • I have not looked at the source code but the algorithm probably expects the x values to line up with the values in the x axis. If you change the data accordingly, then it works as expected. Check [updated fiddle](http://jsfiddle.net/58rw7/3/). You probably already know this, but doing a sanity check :) – FernOfTheAndes Jun 03 '14 at 11:05
  • Thank you for your answer, but this is exactly my problem: the first series must not stack up with the second one. – user1498339 Jun 03 '14 at 11:10
  • I see...do note that the offsets for the "2nd" series are really the dimensions of the "1st" series. In other words, the two "series" ARE stacking up, but just being forced into a different x. – FernOfTheAndes Jun 03 '14 at 11:23

0 Answers0