{
function unpack(rows, key) {
return rows.map(function (row) {
return row[key];
});
}
const markerColor = carsFiltered.map(
(row) => d3.schemeCategory10[row.cylinders]
);
d3.schemeCategory10;
const graphDiv = DOM.element("myDiv");
Plotly.newPlot(
graphDiv,
[
{
type: "scatter",
mode: "markers",
x: unpack(carsFiltered, xDimension),
y: unpack(carsFiltered, yDimension),
marker: { color: markerColor, size: 10 }
}
],
{
title: "Cars",
height: 500,
width: 800,
yaxis: {
title: yDimension,
autorange: true,
type: "linear"
},
xaxis: {
title: xDimension,
autorange: true,
type: "linear"
}
}
);
return graphDiv;
}