问问这个网站中的图表怎么做?

241 天前
 TravisMtg

https://www.newsminimalist.com/

这个可以拖动滑动条,和上方柱形图互动,这种图表有什么现成的开源实现可用吗?

还是得懂点 canvas 自己画?

998 次点击
所在节点    前端开发
2 条回复
llwxi
241 天前
[rc-slider]( https://slider-react-component.vercel.app/demo/range)
[chart.js]( https://www.chartjs.org/docs/latest/samples/bar/floating.html)

```js
{
data: {
labels: n,
datasets: [{
label: "Articles",
data: l,
backgroundColor: "rgba(0, 123, 255, 0.2)",
borderColor: "rgba(0, 123, 255, 0.6)",
borderWidth: 1
}, {
label: "Filtered articles",
data: c,
backgroundColor: "rgba(0, 123, 255, 1)",
borderColor: "rgba(0, 123, 255, 1)",
borderWidth: 0
}]
},
options: {
animation: !1,
maintainAspectRatio: !1,
plugins: {
legend: {
onClick: ()=>{}
,
align: "center",
position: "top",
labels: {
boxHeight: 6,
font: {
size: 14
}
}
}
},
scales: {
y: {
title: {
text: "Number of articles",
color: "#64748b",
font: {
size: 14
}
},
border: {},
ticks: {
beginAtZero: !0,
display: !0,
autoSkip: !0,
maxTicksLimit: 10,
color: "#64748b",
stepSize: 1
},
grid: {
drawBorder: !1,
drawOnChartArea: !1
},
max: "small" === a ? 6 : void 0
},
x: {
stacked: !0,
title: {
display: !1,
text: "News significance",
color: "#64748b",
font: {
size: 14
}
},
ticks: {
align: "center",
maxTicksLimit: 11,
color: "#64748b"
},
grid: {
offset: !1,
drawBorder: !1,
drawTicks: !0,
drawOnChartArea: !1
}
}
}
}
}

```
TravisMtg
241 天前
@llwxi nice

这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。

https://www.v2ex.com/t/1035388

V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。

V2EX is a community of developers, designers and creative people.

© 2021 V2EX