问题标签 [chartjs-2.6.0]
For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.
javascript - React JS 通过 onClick 更改图形 html 代码
嗨,我开始学习 react.js
我想要做的是按下下面的按钮
html代码将加载
但是,它不起作用。如果需要,我可以提供更多信息。感谢您的帮助
chart.js - Put tooltip on the middle of two bars
I'm trying to position a custom Chart.js tooltip on the middle of two bars. I made a research on the chart.js docs and different posts but didn't found any different approach than position it using the following snippet (I'm using jquery and doing a toggle class to hide/show the tooltip, please focus on the values I'm using to position the tooltip):
Using this approach on this particular case I got this result:
[
I also tried using the x
and y
values of the tooltipModel
, however , it doesn't add more sense of how to put the tooltip in the middle. If you tried to add a custom offset to put it on the middle , it works for just this case, but when you add more data it doesn't work. I can have at most 2 datasets, however, the user can add at most 10 data values that means 10 groups of bars.
The question is: There is a way to put the tooltip in the middle of the group of bars (or a single bar in case the user has just 1 dataset) using the values that Chart.js provide for tooltips? Or in other case, do you know any custom approach to have this tooltip centered?
Thanks!!
javascript - chart.js 数据通过 API 根据选择动态形成
我的任务是从 morris.js 转移到 chart.js,我正在尝试根据条件为 chart.js 形成数据。我有多个选择 - 来源、指标、帐户等等。我需要根据这些选择(多选)的值形成数据,例如:
我需要一个折线图,所以我需要一个对象数组(数据集),用于每个选择的选项和颜色、指标 id(选项的值)、日期,因为日期是 Y 轴。解决这个问题的最佳方法是什么?我们已经有一个 API 可以返回如下数据:
- 每天的对象,而不是每个主题的对象。每天可能有空指标/缺失指标。我们通过使用 js 解析选择并使用名称分配基于值的索引并制作自定义 Y 标签和 X 标签来解决此问题。chartjs 的这种方式与我们之前使用的有很大不同。在不需要重新制作 API 的情况下完成这项工作的最佳方法是什么?我很难围绕面向对象的 javascript 进行思考,它与我与之交互的其他语言非常不同,并且创建新对象然后以 javascript 方式将它们推送到数组似乎很奇怪。有小费吗?或者在不知道选择了哪些选择并自动形成数据集而不对值/标签进行硬编码的情况下如何实现这一点的一些示例?
javascript - 从 data.php 中获取数据并传输到 bargraph
data.php 里面的数据是 JSON 格式
我的可视化 bargraph.html 所有大师都无法在该图表上看到任何日期
我的 app.js 从 data.php 获取数据并传输到条形图,但日期没有插入条形图 - 我做错了什么?
javascript - 日期范围选择器和图表 js
我想根据我的日期范围选择器更改图表 js 上的 x 轴标签。如果我选择本周,那么 x 轴标签应该从星期日开始到星期六。如果我选择这个月,那么 x 轴标签应该从 10 月 1 日开始...... 10 月 30 日。如果我选择上个月,那么应该是 9 月 1 日...... 9 月 30 日。如果我选择日期范围,那么它应该应该从开始月份到结束月份。
直到现在我试过这个,但我肯定知道。这是垃圾。
javascript - Chart js:更新具有两个数据集的折线图
我想用两个数据集更新图表 js 中的折线图。我以某种方式设法清空图表,然后能够填写其中一个数据集。但无法使两个数据集都工作。这是代码。
职能:
node.js - 如何使用 Chartjs + Nodejs + Express + Api 消耗在服务器端实时生成图表?
我正在用 nodejs + express + ejs 构建一个系统......这个系统是一个图形面板,为此我选择使用新 Chartjs 2x 的 api......
我知道在客户端使用 Chartjs api,通常当我这样做时,我使用面向对象的 javascript 和 es6 ...
我遇到了什么问题?
当我使用 api 来生成图形时,我不知道图形的数量,更不用说相同的信息(到目前为止很好),但是当我尝试使用 nodejs 时,我想知道最好的我可以选择在服务器端随机生成这些动态图,直接发送到客户端。
我的问题是关于 EJS 中图形的生成和插入,主要是某些图形的操作。
功能示例:
控制器示例: