-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Description
I was looking at the documentation at https://plot.ly/javascript/subplots/
And wanted to create a table of charts, something like:
Where I have multiple charts which describe an item that I have. And then I want to show each row by going through the items.
I tried implementing that with subplots/layout.grid, and first created some traces:
Here are the traces I defined fro both my rows (just dummy data):
Click to view the trace definitions
var row1 = {
scatter: {
type: 'scatter',
x: [1, 2, 3],
y: [4, 5, 6],
xaxis: 'x1',
yaxis: 'y1'
}, bar: {
type: 'bar',
x: ['giraffes', 'orangutans', 'monkeys'],
y: [20, 14, 23],
xaxis: 'x2',
yaxis: 'y2'
}, table: {
type: 'table',
cells: {values: [20, 30, 40]},
header: {values: [50, 60, 70]},
xaxis: 'x3',
yaxis: 'y3'
}, pie: {
type: 'pie',
values: [19, 26, 55],
labels: ['Residential', 'Non-Residential', 'Utility'],
xaxis: 'x4',
yaxis: 'y4'
}
}
var row2 = {
scatter: {
type: 'scatter',
x: [3, 4, 1],
y: [2, 5, 9],
xaxis: 'x5',
yaxis: 'y5'
}, bar: {
type: 'bar',
x: ['giraffes', 'orangutans', 'monkeys'],
y: [30, 12, 34],
xaxis: 'x6',
yaxis: 'y6'
}, table: {
type: 'table',
cells: {values: [10, 50, 20]},
header: {values: [30, 40, 40]},
xaxis: 'x7',
yaxis: 'y7'
}, pie: {
type: 'pie',
values: [4, 6, 9],
labels: ['Residential', 'Non-Residential', 'Utility'],
xaxis: 'x8',
yaxis: 'y8'
}
}
Now ....
Doing:
Plotly.newPlot(
gd,
[row1.scatter, row1.bar, row2.scatter, row2.bar],
{
grid: {rows: 2, columns: 2, pattern: 'independent'},
showlegend: false
});
just breaks the view.
Doing:
Plotly.newPlot(
gd,
[row1.scatter, row1.bar, row2.scatter, row2.bar],
{
grid: {rows: 2, columns: 4, pattern: 'independent'},
showlegend: false
});
It seems to work, but shows a 2x2 grid on the left side of the screen (with the latter 2 columns empty)
I don't fully understand the behavior here and what it is doing.
Maybe this is just cause I don't understand what the configs I need to provide exactly are?
You can check out my trials at:
https://codepen.io/AbdealiJK/pen/EBXBzO