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

Is it possible to create categorical scatter plots?

Open dpantel opened this issue 1 year ago • 4 comments

Description

I am looking to create a categorical scatter plot, where one of the axes contains categories, and the other is numeric. I want to be able to plot multiple sets of data via a category-number coordinate.

Here is an example of a type of plot I am attempting to create.

Is this possible with Billboard?

dpantel avatar Jun 25 '23 17:06 dpantel

via a category-number coordinate.

Can the category be numeric?

date x tick.format
2023/06/01 0.90
2023/06/08 0.95
2023/06/15 1.00 Thur
2023/06/22 1.05
2023/06/29 1.10
2023/06/02 1.90
... ... ...
2023/06/16 2.00 Fri
... ... ...

watnab avatar Jun 27 '23 09:06 watnab

@watnab Yes that might work. I was trying to have the X values as strings, which worked for one data set but not multiple. Using numeric X coordinates and relabeling them seems to be working.

One of the issues in this approach is that if the particular value (X=1 in your example) is not present in the set, then there is no label.

dpantel avatar Jun 28 '23 14:06 dpantel

Using numeric X coordinates and relabeling them if the particular value (X=1 in your example) is not present in the set

var chart = bb.generate({
  data: {
    xs: {data: "data_x"},
    columns: [
	["data_x", 0.95, 1.05, 2.05],
	["data", 10, 5, 7]
    ],
    type: "scatter",
  },
  axis: {
    x: {
      min: 0,
      max: 8,
      tick: {
        values: [1, 2, 3, 4, 5, 6, 7],
        format: function (day) { return "MTWtFSs"[day - 1]; }
      }
    }
  }
});

watnab avatar Jun 29 '23 09:06 watnab

That actually works very well. Thank you

dpantel avatar Jun 29 '23 22:06 dpantel