billboard.js icon indicating copy to clipboard operation
billboard.js copied to clipboard

unexpected grouping for Bar chart

Open mpushki opened this issue 3 years ago • 6 comments

Description

When I use xs and bar chart - I expect to be ungrouped

  data: {
    xs: {
      data1: "x1",
      data2: "x2"
    },
    columns: [
	    ["x1", 1, 2, 3, 4, 5],
            ["x2", 1, 2, 4, 5, 6],
	    ["data1", 4, 1, 6, 8, 10],
            ["data2", 5, 2, 6, 7, 8]
    ],
    type: "bar", // for ESM specify as: line()
  },

Steps to check or reproduce

https://jsfiddle.net/mpushki/eu2o561x/2/

mpushki avatar May 21 '21 14:05 mpushki

It seems:

  • xs + bar -> grouped.
  • xs + area -> ungrouped.
  • xs + area + groups -> ungroupd.
  • xs + bar + groups -> grouped. Wrong? autoscale of y axis.

watnab avatar May 24 '21 00:05 watnab

Hi @mpushki, is there any reason to use same xs? The data bound to different xs, will make data to be rendered as in different x scales for each data series.

netil avatar May 24 '21 03:05 netil

  • xs + bar -> grouped.
  • xs + bar + groups -> grouped. Wrong? autoscale of y axis.

I thought "data1" and "data2" were stacked(grouped). However "data1" seems to overlap with "data2".

watnab avatar May 24 '21 04:05 watnab

Hi @mpushki, is there any reason to use same xs? The data bound to different xs, will make data to be rendered as in different x scales for each data series.

I just used to c3js. And i'm in migration to billboard and option has unexpected behavior for me as I show it above.

About reason: I have large amount data with different x and show it on one chart. It makes no sense to run through a huge array if there is only one value for a particular case. So for each data stream I have a different x.

mpushki avatar May 24 '21 07:05 mpushki

https://github.com/naver/billboard.js/blob/af1937054c7659158b4bf893db53b7aebfcc1bc0/src/ChartInternal/shape/bar.ts#L143 The value of barTargetsNum is 1 but it may be the value should be 2 in this case. It may be barIndices has wrong value.

watnab avatar May 25 '21 08:05 watnab

well, this mainly comes from treating xs as different scale space even they're having same x tick values. (Ref. #1115) Checkout the difference on billboard.js(left screenshot) and C3.js(right screenshot), with below generation option.

bb.generate({
  data: {
    xs: {
      "Sep": "x1",
      "Jul": "x2",
      "Aug": "x2"
    },
    type: "bar",
    columns: [
      ["x1", "05"],
      ["x2", "01", "08", "29"],
      ["Sep", 2],
      ["Jul", 1, 1, 1],
      ["Aug", 2, 2, 2]
    ]
  }
})

Will notice that right screenshot's bars aren't positioned correctly.

netil avatar May 28 '21 09:05 netil