Highcharts yaxis ที่ 2 ไม่ได้ปรับขนาด

ฉันมองเห็นแกน 2 แกน แต่ฉันจะขยายแกนที่สองได้อย่างไร ต้องใส่โค้ดตรงไหน? ฉันได้ข้อมูลจากฐานข้อมูลโดยใช้ json.php ซึ่งฉันไม่ได้รวมเอาไว้ เพราะมั่นใจว่าได้ผลลัพธ์...อย่างที่บอกไปว่ามองเห็นเส้นได้........

function InitHighChart()
{
$("#chart").html("Wait, Loading graph...");

var options = {
    chart: {
        renderTo: 'chart',
        borderColor: '#a1a1a1',
        borderWidth: 2,
        borderRadius: 13,
        alignTicks: false,
        height: 550
    },
    credits: {
        enabled: false
    },
    title: {
        text: 'Ενεργός Ισχύς / Τάση',
        x: -20
    },
    xAxis: {
        categories: [{}],
        labels: {
            step: 15,
            rotation: -75
        }
    },

     yAxis: [{ // Primary yAxis
        labels: {
            format: '{value} MWatt',


        },
        title: {
            text: 'Ενεργός Ισχύς',

        }

    }, { // Secondary yAxis
        title: {
            text: 'Τάση',

        },
        labels: {
            format: '{value} V',

        },
        opposite: true
    }],


    tooltip: {
        formatter: function() {
            var s = '<b>'+ this.x +'</b>';

            $.each(this.points, function(i, point) {
                s += '<br/>'+point.series.name+': '+point.y;
            });

            return s;
        },
        shared: true
    },
    series: [{},{}]
};

$.ajax({
    url: "json.php",
    data: 'show=impression',
    type:'post',
    dataType: "json",
    success: function(data){

        options.xAxis.categories = data.datetime;
        options.series[0].name = '...';
        options.series[0].data = data.ActiveData;
        options.series[1].name = '...';
        options.series[1].data = data.VoltageData;

        var chart = new Highcharts.Chart(options);          
    },
});

}

person user2761225    schedule 05.12.2014    source แหล่งที่มา
comment
ตามขนาด คุณหมายถึงตั้งค่า tickInterval ที่แตกต่างกันหรือไม่ จัดแนว เห็บหรือไม่   -  person Sebastian Bochan    schedule 05.12.2014
comment
ลิงค์ที่สอง...ฉันหมายถึง..yaxis1 เพื่อปรับขนาดตามข้อมูล yaxis1 และ yaxis2 ตามข้อมูล yaxis2 ฉันได้รับ yaxis ด้านซ้ายเพียงอันเดียวเท่านั้น..ฉันไม่เห็นอันที่ถูกต้อง..ขอบคุณ   -  person user2761225    schedule 05.12.2014


คำตอบ (1)


คุณได้กำหนดอนุกรมให้กับแกน y ที่สองแล้วหรือยัง? นั่นอาจเป็นปัญหา

API: http://api.highcharts.com/highcharts#series.yAxis

series: [{
        data: [1, 2, 3, 4, 5, 3, 5]
    }, {
        data: [3, 3, 5, 4, 6, 6, 3, 3, 4, 6],
        yAxis: 1
}]

jsFiddle: http://jsfiddle.net/boog4dpe/

ในรหัสของคุณคุณควรเพิ่มบรรทัดเข้าไป

$.ajax({
    url: "json.php",
    data: 'show=impression',
    type:'post',
    dataType: "json",
    success: function(data){

        options.xAxis.categories = data.datetime;
        options.series[0].name = '...';
        options.series[0].data = data.ActiveData;
        options.series[1].name = '...';
        options.series[1].data = data.VoltageData;

        options.series[1].yAxis = 1; //added line

        var chart = new Highcharts.Chart(options);          
    },
});
person Kacper Madej    schedule 05.12.2014
comment
options.series[1].data = data.VoltageData; ทำให้สิ่งนี้ ฉันได้รับข้อมูลจากการสืบค้นฐานข้อมูล...มีวิธีอื่นในการส่งข้อมูลโดยใช้รูปแบบโค้ดตามที่คุณเขียนหรือไม่ ฉันยังใหม่กับ Highcharts... ดูตัวอย่างบางส่วนแล้ว วิธีที่ฉันทำแสดงให้เห็นสองบรรทัด แต่ไม่ใช่ yaxis ที่สอง... ขอบคุณมาก - person user2761225; 05.12.2014