第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問題,去搜搜看,總會(huì)有你想問的

無法修改作為全局變量初始化的 highcharts

無法修改作為全局變量初始化的 highcharts

浮云間 2021-11-25 19:18:36
我在玩highcharts?,F(xiàn)在我知道我想要什么了,我試圖創(chuàng)建一個(gè)簡(jiǎn)單的邏輯來動(dòng)態(tài)更新數(shù)據(jù)(xaxis 類別)及其系列。但我被困在基礎(chǔ)知識(shí)上。我無法從一個(gè)簡(jiǎn)單的函數(shù)訪問 highchart,盡管它是一個(gè)全局變量。    <script>        var myChart;        $(document).ready(function() {            init();        });        function init(){            myChart = $('#graph-container').highcharts({                title: {                    text: 'Dummy Title'                },                xAxis: {                    categories: ['Dummy1', 'Dummy2']                },                series: []            });        }        function onclickButton(){            //myChart.xAxis[0].setCategories(['A','B']);            myChart.addSeries({                    name: 'John',                    data: [['A',1], ['B',2]]                });        }    </script></head><body>    <div id="graph-container" style="width:100%; height:400px;"></div>    <input type="button" value="Click me" onclick="onclickButton()"></body></html>它說 xAxis 未定義,或者 addSeries 函數(shù)不存在。我究竟做錯(cuò)了什么?
查看完整描述

1 回答

?
守候你守候我

TA貢獻(xiàn)1802條經(jīng)驗(yàn) 獲得超10個(gè)贊

結(jié)帳我的snipet,希望它可以幫助你。祝你今天過得愉快!


<html>


<head>

  <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>

  <script src="https://code.highcharts.com/highcharts.js"></script>

  <script>

    var myChart;


    $(document).ready(function() {

      init();

    });


    function init() {

      myChart = Highcharts.chart('graph-container', {

        title: {

          text: 'Dummy Title'

        },

        xAxis: {

          categories: ['Dummy1', 'Dummy2']

        },

        series: []

      });

    }


    function onclickButton() {

      myChart.addSeries({

        name: 'John',

        data: [

          ['A', Math.floor(Math.random() * 10)],

          ['B', Math.floor(Math.random() * 10)]

        ]

      });

    }

  </script>

</head>


<body>

  <div id="graph-container" style="width:100%; height:400px;"></div>

  <input type="button" value="Click me" onclick="onclickButton()">

</body>


</html>


查看完整回答
反對(duì) 回復(fù) 2021-11-25
  • 1 回答
  • 0 關(guān)注
  • 185 瀏覽
慕課專欄
更多

添加回答

舉報(bào)

0/150
提交
取消
微信客服

購(gòu)課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)