-
I am wondering if it is possible to limit the number of bars in a bar chart after using Because the dataset needs to be reduced first, I'm not sure where to in The solution I would know, is grouping the data first and then just use the bar marks without the groupX, but the goal of my exercise is to use as many transformations as possible with Plot. An additional requirement would be to combine the remaining values and group to an "others" bar. This is the example I am starting with: const barChart = Plot.plot({
marginLeft: 400,
width: 900,
height: 300,
padding: 0.1,
x: {
axis: null,
},
y: {
padding: 0.15,
label: null,
},
marks: [
Plot.barX(
eventDataCompare,
Plot.groupY(
{
x: (d) => {
const total = d3.sum(d, (i) => i.record_count);
return total;
},
},
{
y: "page_title",
sort: { y: "-x" },
limit: 5,
fill: "#3FA0B1",
}
)
),
Plot.ruleX([0]),
Plot.axisY({
fontSize: 16,
tickSize: 0,
}),
],
});
|
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 4 replies
-
I found the property That solves already issue # 1 - limiting bars:
Still digging to find out how to aggregate the remaining bars. Note: |
Beta Was this translation helpful? Give feedback.
I found the property
limit
!That solves already issue # 1 - limiting bars:
Still digging to find out how to aggregate the remaining bars.
A solution could be to create a separate mark ... ?!
Note:
limit
isn't part of the Plot documentation. At least not in thesort
page and theAPI index