海绵宝宝撒
添加我之前的评论后,我一直在玩这个,你也可以这样做(这已经满足了):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}}]);