1 回答

TA貢獻1809條經驗 獲得超8個贊
添加我之前的評論后,我一直在玩這個,你也可以這樣做(這已經滿足了):
data: '6,5,7,3,7,9,10'.split(','),
這只是將字符串拆分為數組,然后通過 RGraph 將值轉換為數字。
在 RGraph 的下一個版本 (v5.27) 中,您將不需要調用 split()。
這里有一個演示,它對數據調用 split() 函數:
https://www.rgraph.net/demos/bar-basic.html
其代碼是這樣的:
new RGraph.Bar({
id: 'cvs',
data: '12,18,10,9,6,20,18'.split(','),
options: {
yaxisScaleUnitsPost: 'k',
colors: ['red'],
title: 'A basic Bar chart using accessible text',
titleBold: true,
xaxis: false,
yaxis: false,
marginLeft: 50,
tooltips: '%{key}',
tooltipsFormattedUnitsPost: '%',
tooltipsCss: {
fontSize: '26pt'
},
tooltipsFormattedKeyLabels: ['Dave','John'],
tooltipsEvent: 'mousemove'
}
}).draw().responsive([
{maxWidth:900,width:400,height:150,options: {textSize:10,xaxisLabels:['Mon\n(yuck!)','Tue','Wed','Thu','Fri\n(woo!)','Sat','Sun'],marginInner: 10}},
{maxWidth:null,width:750,height:250,options: {textSize:14,xaxisLabels: ['Monday\n(yuck!)','Tuesday','Wednesday','Thursday','Friday\n(woo!)','Saturday','Sunday'],marginInner: 20}}
]);
添加回答
舉報