实用程序的输出格式是什么?(使用vanillajs中的chartjs,而不是react/angular)

2eafrhcq  于 2022-11-06  发布在  Chart.js
关注(0)|答案(1)|浏览(175)

我尝试从数据文件中加载气泡图的数据,示例使用chartjs函数生成数据。
通过一些示例,希望通过d3.js加载csv/json文件,因为将使用来自api和前端的数据文件,而不是react/angular。
到目前为止的示例。https://github.com/aspiringguru/chartjs_3.7.1_vanilla
我看不到示例中使用的Utils.* 的输出格式。
expecting将需要每个点的x,y,半径。只需要计算出chartjs期望的数据格式。
https://www.chartjs.org/docs/next/samples/other-charts/bubble.html使用

data: Utils.bubbles(NUMBER_CFG)

dataset.data = Utils.bubbles({count: chart.data.labels.length, rmin: 5, rmax: 15, min: 0, max: 100});

我看了一下https://github.com/chartjs/Chart.js/blob/master/docs/scripts/utils.js,但无法理解生成的输出

function bubbles(config)
zkure5ic

zkure5ic1#

气泡图的数据结构由一个包含对象的数组组成,每个对象都有一个x键表示x值,一个y键表示y值,一个r键表示半径。
第一个

相关问题