billboard.js
billboard.js copied to clipboard
Is it possible to create categorical scatter plots?
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?
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 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.
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]; }
}
}
}
});
That actually works very well. Thank you