0

JavaScriptに関しては全くの初心者ですので、コーディングの悪さはご容赦ください。

私は Highchart を使用してプロジェクトに取り組んでおり、ファイルの値を読み取りたいと考えています (実際にはファイルを配列に読み取り、特定の値を取得します - 他のグラフには他の値を使用します)。

ここで他の人の助けを借りて、配列の値を HTML に表示できるようになりましたが、これをハイチャートに渡すことはできません。

私のプロトタイプ ページ (出力を確認できるように) は次の場所にあります。

http://maccas.chickenkiller.com/1.html

コードは

<html debug="false">
    <head>
        <title>Adam's hacked up demo</title>
        <META HTTP-EQUIV="refresh" CONTENT="300">
        <script src="http://code.jquery.com/jquery-1.9.1.js"></script>
        <script src="http://code.highcharts.com/highcharts.js"></script>
        <script src="http://code.highcharts.com/highcharts-more.js"></script>
        <script src="http://code.highcharts.com/modules/exporting.js"></script>
    </head>

<script>

jQuery(function($){ // encapsulate jQuery
    $.ajax(
        {
            url:'livedata.txt',
            async:false,
            success: function(data){
            livedata = data.split(',');
            }
        });

    function drawGraph(phvalue) {
    var phvalue=livedata[3];
        var chart = new Highcharts.Chart({
            chart: {
                renderTo: 'container',
                type: 'gauge',
                plotBackgroundColor: null,
                plotBackgroundImage: null,
                plotBorderWidth: 0,
                plotShadow: false
            },

            title: {
                text: 'live pH'
            },
                    pane: {
                startAngle: -150,
                endAngle: 150,
                background: [{
                    backgroundColor: {
                        linearGradient: { x1: 0, y1: 0, x2: 0, y2: 1 },
                        stops: [
                            [0, '#FFF'],
                            [1, '#333']
                        ]
                    },
                    borderWidth: 0,
                    outerRadius: '109%'
                }, {
                    backgroundColor: {
                        linearGradient: { x1: 0, y1: 0, x2: 0, y2: 1 },
                        stops: [
                            [0, '#333'],
                            [1, '#FFF']
                        ]
                    },
                    borderWidth: 1,
                    outerRadius: '107%'
                }, {
                    // default background
                }, {
                    backgroundColor: '#DDD',
                    borderWidth: 0,
                    outerRadius: '105%',
                    innerRadius: '103%'
                }]
            },

            // the value axis
            yAxis: {
                min: 8,
                max: 9,

                minorTickInterval: 'auto',
                minorTickWidth: 1,
                minorTickLength: 10,
                minorTickPosition: 'inside',
                minorTickColor: '#666',

                tickPixelInterval: 30,
                tickWidth: 2,
                tickPosition: 'inside',
                tickLength: 10,
                tickColor: '#666',
                labels: {
                    step: 2,
                    rotation: 'auto'
                },
                plotBands: [{
                    from: 8,
                    to: 8.3,
                    color: '#55BF3B' // green
                }, {
                    from: 8.3,
                    to: 8.7,
                    color: '#DDDF0D' // yellow
                }, {
                    from: 8.7,
                    to: 9,
                    color: '#DF5353' // red
                }]
            },

            series: [{
                name: 'Current pH',
                data: [phvalue],
                tooltip: {
                        valueSuffix: ' pH'
                }
            }]
        });
    }

    $(document).ready(function () {
        drawGraph();
    });

});
</script> 

<body>
    <table>
            <tr>
                <td><div id="container" style="width:90%; height:400px;"></div></td>
            </tr>
    </table>
</body>
</html>

var phvalue をハイチャートに表示する方法を知っている人はいますか?

前もって感謝します。

4

2 に答える 2

0

これは驚くほど複雑でした。あなたがしたい:

$('#container').highcharts().series[0].points[0].update(x)

x更新したい番号はどこですか

于 2013-06-15T06:34:26.607 に答える