亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

無法將數組值輸入到圖表中

無法將數組值輸入到圖表中

繁星淼淼 2023-09-28 15:50:08
我正在使用 Rgraph 來繪制折線圖。我正在嘗試使用 Javascript 將值輸入到圖表中。這是例行公事..        function update_day_temp(newval){        var newval = '6,5,7,3,7,9,10';        var dta = [];        dta = newval.split(',');        console.log('data ' + dta);                day_temp = new RGraph.Line({            id: 'day_temp',//          data: dta,            data: [6,5,7,3,7,9,10],            options: {            }        }).draw()    };如果我使用使用過的數據,一切都很好。但如果我使用 dta 那么我確實會得到結果。
查看完整描述

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}}

]);


查看完整回答
反對 回復 2023-09-28
  • 1 回答
  • 0 關注
  • 113 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號