krispo / angular-nvd3

AngularJS directive for NVD3 reusable charting library (based on D3). Easily customize your charts via JSON API.
http://krispo.github.io/angular-nvd3
MIT License
1.29k stars 377 forks source link

HistoricalBarChart: how to make bars NOT overlap? #643

Open thany opened 7 years ago

thany commented 7 years ago

I'm getting this: capture How do I make the bars NOT overlap?

Even if I copypaste the configuration of the example, I will still get the result above - or at least similar, with overlapping bars.

My data is as follows:

const data = [
  {
    "key": "movement",
    "strokeWidth": 1,
    "values": [
      { "x": 1488780000, "y": 47 },
      { "x": 1488790800, "y": 205 },
      { "x": 1488801600, "y": 100 },
      { "x": 1488812400, "y": 40.33 },
      { "x": 1488866400, "y": 10 },
      { "x": 1488898800, "y": 97 },
      { "x": 1488909600, "y": 3 },
      { "x": 1488952800, "y": 216 },
      { "x": 1488963600, "y": 170.66 },
      { "x": 1489039200, "y": 301 },
      { "x": 1489050000, "y": 150.66 },
      { "x": 1489060800, "y": 206.33 },
      { "x": 1489071600, "y": 156.5 },
      { "x": 1489384800, "y": 13 },
      { "x": 1489395600, "y": 57.66 },
      { "x": 1489406400, "y": 141 },
      { "x": 1489417200, "y": 0 },
      { "x": 1489492800, "y": 194.66 },
      { "x": 1489503600, "y": 80 },
      { "x": 1489557600, "y": 78 }
    ]
  }
]

How can I fix this? I want the bars to leave a pixel or so of space between them. Or at the very least, not have them overlap.

Versions: AngularJS 1.6.2 Angular-NVD3 1.0.9 NVD3 1.8.5 D3 3.5.17

thany commented 7 years ago

Is there a way to force the amount of space between bars? I'm sure this is wrongly calculated automatically... Somewhere. Or is there a way to force the width of bars, which might also be calculated automatically and have some bug in it.

The documentation is very unclear on this.

DaliborTakac commented 7 years ago

had similar issue, tracked the issue down to the fact that data does not contain data points for every date (data contains holes), if those dates without data points are artificially filled in with 0 y values graph renders ok, but still no way to control spacing between the bars

example http://plnkr.co/edit/2wduaFyLpxthmLhtD60b?p=preview

shnigi commented 6 years ago

I have this same problem even though I don't have gapps in the data.