javascript - How to Create Chart.JS Bar Graph with Min, Max & Average
问题描述
I have an app that is generating some bart charts from a service. My client added an additional chart to display a range (min, max and average). I was wondering if their is a way to accomplish this using chart.js. I looked through their docs and wasn't able to find any examples or documentation on how to accomplish this. Anyone else run into this or have a different library they prefer?
解决方案
You can combine "floating bars" and "stacked bar chart". See https://codepen.io/fantasyzer/pen/KKaqgoM for an example. Note that the data
of each bar is given as an array [Ybegin,Yend]. If you set stackable
to false
for the y scale the values are to be given as absolute:
datasets: [
{
data: [
[10,12],
[20,25],
[15,25],
[25,28],
...
Ref: https://www.chartjs.org/docs/latest/samples/bar/floating.html, https://www.chartjs.org/docs/latest/samples/bar/stacked.html
推荐阅读
- python - Selenium 和 Pandas 在页面中抓取表格
- r - 在 R 中使用 facet_wrap 创建密度图,添加代表其他列的线和数据点
- javascript - 如何使用代码生成来做 Angular 类型的表单
- regex - 电话号码 (XXX) XXXXXXX 的正则表达式是什么
- python-3.x - NER:为 Spacy v3 定义训练数据
- ios - 合并发布者时如何处理错误?
- python - Heroku - 上传 Django-App 时应用与 buildpack 不兼容 https://github.com/heroku/heroku-buildpack-python.git
- node.js - JSON.parse() 出现意外错误:“JSON 输入意外结束”
- java - 如何使用 PDFBox 库在 pdf 文档的开头插入文本并向下移动页面内容的其余部分?
- maven - 通过 tomcat-maven-plugin 部署到 Tomcat 时出现“软件导致连接中止:套接字写入错误”