我正在嘗試從資料檔案中加載氣泡圖的資料,這些示例使用 chartjs 函式來生成資料。
通過一些示例,希望通過 d3.js 加載 csv/json 檔案,因為將使用來自 api 和前端的資料檔案,而不是在 react/angular 中。
到目前為止的例子。 https://github.com/aspiringguru/chartjs_3.7.1_vanilla
我看不到示例中使用的 Utils.* 的輸出格式。
期望每個點都需要 x,y,radius。只需要弄清楚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)
uj5u.com熱心網友回復:
可以在檔案中閱讀此處。氣泡圖的資料結構由一個包含物件的陣列組成,其中每個物件都有一個用于 x 值的 x 鍵、一個用于 y 值的 y 鍵和一個用于半徑的 ar 鍵。
{
// X Value
x: number,
// Y Value
y: number,
// Bubble radius in pixels (not scaled).
r: number
}
const data = [{x: 5, y: 7, r: 9}, {x: 6, y: 3, r: 1}];
轉載請註明出處,本文鏈接:https://www.uj5u.com/houduan/482534.html
