0

.csv ファイルから Highcharts にデータをロードする際に問題が発生しました。

私の最終的な目標は、(実際のサンプル)からデータをロードすることです

http://maccas.chickenkiller.com/24hr_final.csv

で説明されている方法のわずかなバリエーションを使用して、データをハイチャートに入れることができます

http://docs.highcharts.com/#preprocesssing-data-from-a-file

問題は、この方法を使用すると、異なるシリーズ軸を分離できないことです。

私のデータにはシリーズ (上記の .csv ファイルを参照) があり、1 セットは 8 ~ 9 の範囲、3 セットは 23 ~ 30 の範囲、最後のセットは 350 ~ 450 の範囲です。

私の目標は、一連の「ORP」を第 2 軸 (右側) に移動し、「pH」を第 3 軸 (左側) に移動することです。

シリーズをプライマリ、セカンダリ、およびターシャリ軸にバインドするオプションには自信がありますが、これを可能にする方法でデータをシリーズにロードすることはできません。

以下は、「毎日」タブ グラフを生成するための関連コードです。

$(function () {
    var dailychartoptions = {
        credits: {
            enabled: false
            },
        plotOptions: {
            line: {
                marker: {
                    enabled: false
                }
            }
            },
        chart: {
        renderTo: 'dailychart',
            type: 'line',
            marginRight: 130,
            marginBottom: 25,
            zoomType: 'x',
            spacingRight: 2
    },
    title: {
            text: '24hr history',
                x: -20 //center
    },
    subtitle: {
            text: 'Temp',
            x: -20
        },
    xAxis: {
        tickInterval:60,
            categories: []
        },
    yAxis: [{ //Primary [0]
        title: {
            text: 'orp'
        },
        min: 0
    },
    { //Secondary [1]
        title: {
            text: 'Temp'
        },
        opposite: true
    },
    { //Tertiary [2]
        title: {
            text: 'pH'
        },
        opposite: true
        }],
    tooltip: {
            crosshairs: true,
            shared: true
        },
        legend: {
            layout: 'vertical',
            align: 'right',
            verticalAlign: 'top',
            x: -10,
//              y: 100,
            borderWidth: 1
        },
    series: []
};

    $.get('24hr_final.csv', function(data) {
// Split the lines
        var lines = data.split('\n');
        $.each(lines, function(lineNo, line) {
            var items = line.split(',');
//Below is an attempt to change UNIX EPOCH to Java EPOCH and load into series1 as a date
            if (lineNo == 0) {
                $.each(items, function(itemNo, item) {
                    if (itemNo > 0) {
                                var javaepoch = (item)/0.001;
                                var date = new Date(javaepoch);
                                dailychartoptions.xAxis.categories.push(date);
                    }
                });
            }
// the rest of the lines contain data with their name in the first position
            else {
                var series = { 
                    data: []
                };
                $.each(items, function(itemNo, item) {
                    if (itemNo == 0) {
                        series.name = item;
// Added the below to try and set the yaxis value                       
                        if (item = 'pH' ) {
                            series.yAxis = 0;
                        }
// Finished mods for axis

                    } else 
                    {
                        series.data.push(parseFloat(item));
                    }
                });
                dailychartoptions.series.push(series);
                }
            });
        var chart = new Highcharts.Chart(dailychartoptions);
        });
});
4

1 に答える 1