2016-05-24 12 views
0

stackchartをハイチャートの積み上げ縦棒グラフに保持する方法はありますか?yAxisを隠す方法はありますか?HighCharts stackLabelsが非表示のyAxisで表示される

HCの著者からthis fiddleを借りて問題を表示しました。 yAxisの可視性を切り替えることができ、これによってスタックラベルを切り替えることもできます。

マイHighChartsコードは次のとおりです。

$(function() { 

    // Configure the chart 
    $('#container').highcharts({ 

    chart: { 
     type: 'column' 
    }, 

    title: { 
     text: 'Highcharts axis visibility' 
    }, 

    xAxis: { 
     categories: ['Apples', 'Pears', 'Oranges', 'Peaches'] 
    }, 

    yAxis: { 
     allowDecimals: false, 
     title: { 
     text: 'Fruit' 
     }, 
     stackLabels: { 
     enabled: true 
     }, 
     visible: false 
    }, 

    plotOptions: { 
     series: { 
     stacking: 'normal', 
     dataLabels: { 
      enabled: true 
     } 
     } 
    }, 

    series: [{ 
     data: [1, 3, 2, 4], 
     name: 'Ola' 
    }, { 
     data: [5, 4, 5, 2], 
     name: 'Kari' 
    }] 

    }); 

    var yVis = false, 
    xVis = true; 
    $('#toggle-y').click(function() { 
    yVis = !yVis; 
    $('#container').highcharts().yAxis[0].update({ 
     visible: yVis 
    }); 
    }); 
    $('#toggle-x').click(function() { 
    xVis = !xVis; 
    $('#container').highcharts().xAxis[0].update({ 
     visible: xVis 
    }); 
    }); 
}); 

stackLabelsが隠しY軸で見ることができますか?

答えて

2

可視性を設定する代わりに、yAxisの要素を操作できます。

$('#toggle-y').click(function() { 
     yVis = !yVis; 
     $('#container').highcharts().yAxis[0].update({ 
      labels: { 
      enabled: yVis 
     }, 
     gridLineWidth: yVis ? 1 : 0, 
     title:{ 
      enabled: yVis 
     } 
     }); 
    }); 

例:

関連する問題