1 回答

TA貢獻(xiàn)1809條經(jīng)驗(yàn) 獲得超8個(gè)贊
添加我之前的評(píng)論后,我一直在玩這個(gè),你也可以這樣做(這已經(jīng)滿足了):
data: '6,5,7,3,7,9,10'.split(','),
這只是將字符串拆分為數(shù)組,然后通過(guò) RGraph 將值轉(zhuǎn)換為數(shù)字。
在 RGraph 的下一個(gè)版本 (v5.27) 中,您將不需要調(diào)用 split()。
這里有一個(gè)演示,它對(duì)數(shù)據(jù)調(diào)用 split() 函數(shù):
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}}
]);
添加回答
舉報(bào)