2017-05-04 40 views
1

試圖創建一個3列系列和1個分散系列的組合圖;列應爲100%並散佈在其上。當我使用plotOptions:{column:{stacking:「percent」}時,列在繪圖區域中最大化,但分散系列移至圖表底部;當用plotOptions替換時:{column:{stacking:「normal」},它顯示良好,但列不能最大化繪圖區域。想法?如何讓highcharts combo column scatter工作?

Highcharts.chart('container', { 
 
     chart: { 
 
     ignoreHiddenSeries: false, 
 
     backgroundColor: "#FFFFFF", 
 
     width: 509, 
 
     height: 400, 
 
     borderColor: "#FFFFFF", 
 
     borderWidth: 1, 
 
     plotShadow: false 
 
    }, 
 
    title: { 
 
     text: "Your organization in comparison", 
 
     style: {color: "#333333", fontFamily: "Arial", fontSize: 16, fontWeight: "bold"} 
 
    }, 
 
    legend: { 
 
     enabled: true, 
 
     verticalAlign: "bottom", 
 
     align: "center", 
 
     symbolRadius: 0, 
 
     style: {color: "#333333", fontFamily: "Arial", fontSize: 13} 
 
    }, 
 
    plotOptions: { 
 
     column: {stacking: "percent"}, 
 
//  column: {stacking: "normal"}, 
 
     series: {animation: true}}, 
 
    tooltip: {enabled: false}, 
 
    yAxis: {title: {text: null}, labels: {enabled: false}, gridLineWidth: 0, reversedStacks: false}, 
 
    xAxis: { 
 
     title: {text: null}, 
 
     categories: ['Experience', 'Security', 'Management'], 
 
     labels: {enabled: true, style: {color: "#333333", fontFamily: "Arial", fontSize: 13}}, 
 
     gridLineWidth: 0, 
 
     reversedStacks: false 
 
    }, 
 
    series: [{ 
 
     type: "column", 
 
     name: "Low", 
 
     invertIfNegative: false, 
 
     color: "#002E73", 
 
     showInLegend: true, 
 
     data: [{y: 0.42}, {y: 0.42}, {y: 0.48}], 
 
     dataLabels: { 
 
      enabled: false, 
 
      verticalAlign: "top", 
 
      style: {color: "#FFFFFF", fontFamily: "Arial", fontSize: 13, textOutline: ""} 
 
     } 
 
    }, { 
 
     type: "column", 
 
     name: "Medium", 
 
     invertIfNegative: false, 
 
     color: "#297EFF", 
 
     showInLegend: true, 
 
     data: [{y: 0.37}, {y: 0.47}, {y: 0.36}], 
 
     dataLabels: {enabled: false} 
 
    }, { 
 
     type: "column", 
 
     name: "High", 
 
     invertIfNegative: false, 
 
     color: "#B8D4FF", 
 
     showInLegend: true, 
 
     data: [{y: 0.21}, {y: 0.11}, {y: 0.16}], 
 
     dataLabels: {enabled: false} 
 
    }, { 
 
     type: "scatter", 
 
     name: "Your organization today", 
 
     invertIfNegative: false, 
 
     color: "#FFC000", 
 
     lineWidth: 0, 
 
     marker: {enabled: true, radius: 14}, 
 
     states: {hover: {lineWidthPlus: 0}}, 
 
     showInLegend: true, 
 
     data: [{y: 0.21}, {y: 0.21}, {y: 0.24}], 
 
     dataLabels: {enabled: false} 
 
    }], 
 
    credits: {enabled: false} 
 
}) 
 

 
<script src="https://code.highcharts.com/highcharts.js"></script> 
 
<script src="https://code.highcharts.com/highcharts-more.js"></script> 
 
<script src="https://code.highcharts.com/modules/exporting.js"></script> 
 

 
<div id="container" style="width: 600px; height: 300px; margin: 0 auto"></div>

+1

你試過用100乘以散射值?列自行縮放範圍爲0-100(因爲「堆疊:」百分比「'),但散點仍然很小(0.21或0.24)。 –

回答

-1

你應該使用多軸進行組合圖。

參考文獻關於y軸的位置:http://api.highcharts.com/highcharts/yAxis

我已經固定的代碼爲波紋管。請嘗試!

Highcharts.chart('container', { 
 
    chart: { 
 
    ignoreHiddenSeries: false, 
 
    backgroundColor: "#FFFFFF", 
 
    width: 509, 
 
    height: 400, 
 
    borderColor: "#FFFFFF", 
 
    borderWidth: 1, 
 
    plotShadow: false 
 
    }, 
 
    title: { 
 
    text: "Your organization in comparison", 
 
    style: { 
 
     color: "#333333", 
 
     fontFamily: "Arial", 
 
     fontSize: 16, 
 
     fontWeight: "bold" 
 
    } 
 
    }, 
 
    legend: { 
 
    enabled: true, 
 
    verticalAlign: "bottom", 
 
    align: "center", 
 
    symbolRadius: 0, 
 
    style: { 
 
     color: "#333333", 
 
     fontFamily: "Arial", 
 
     fontSize: 13 
 
    } 
 
    }, 
 
    plotOptions: { 
 
    column: { 
 
     stacking: "percent" 
 
    }, 
 
    //  column: {stacking: "normal"}, 
 
    series: { 
 
     animation: true 
 
    } 
 
    }, 
 
    tooltip: { 
 
    enabled: false 
 
    }, 
 

 
    // Create Multiple axes 
 
    yAxis: [{ 
 
    title: { 
 
     text: null 
 
    }, 
 
    labels: { 
 
     enabled: false 
 
    }, 
 
    gridLineWidth: 0, 
 
    reversedStacks: false 
 
    }, { 
 
    title: { 
 
     text: null 
 
    }, 
 
    labels: { 
 
     enabled: false 
 
    }, 
 
    gridLineWidth: 0, 
 
    reversedStacks: false 
 
    }], 
 

 
    xAxis: { 
 
    title: { 
 
     text: null 
 
    }, 
 
    categories: ['Experience', 'Security', 'Management'], 
 
    labels: { 
 
     enabled: true, 
 
     style: { 
 
     color: "#333333", 
 
     fontFamily: "Arial", 
 
     fontSize: 13 
 
     } 
 
    }, 
 
    gridLineWidth: 0, 
 
    reversedStacks: false 
 
    }, 
 
    series: [{ 
 
    type: "column", 
 
    name: "Low", 
 
    invertIfNegative: false, 
 
    color: "#002E73", 
 
    showInLegend: true, 
 
    data: [{ 
 
     y: 0.42 
 
    }, { 
 
     y: 0.42 
 
    }, { 
 
     y: 0.48 
 
    }], 
 
    dataLabels: { 
 
     enabled: false, 
 
     verticalAlign: "top", 
 
     style: { 
 
     color: "#FFFFFF", 
 
     fontFamily: "Arial", 
 
     fontSize: 13, 
 
     textOutline: "" 
 
     } 
 
    } 
 
    }, { 
 
    type: "column", 
 
    name: "Medium", 
 
    invertIfNegative: false, 
 
    color: "#297EFF", 
 
    showInLegend: true, 
 
    data: [{ 
 
     y: 0.37 
 
    }, { 
 
     y: 0.47 
 
    }, { 
 
     y: 0.36 
 
    }], 
 
    dataLabels: { 
 
     enabled: false 
 
    } 
 
    }, { 
 
    type: "column", 
 
    name: "High", 
 
    invertIfNegative: false, 
 
    color: "#B8D4FF", 
 
    showInLegend: true, 
 
    data: [{ 
 
     y: 0.21 
 
    }, { 
 
     y: 0.11 
 
    }, { 
 
     y: 0.16 
 
    }], 
 
    dataLabels: { 
 
     enabled: false 
 
    } 
 
    }, { 
 
    yAxis: 1, // Define axis will be use here 
 
    type: "scatter", 
 
    name: "Your organization today", 
 
    invertIfNegative: false, 
 
    color: "#FFC000", 
 
    lineWidth: 0, 
 
    marker: { 
 
     enabled: true, 
 
     radius: 14 
 
    }, 
 
    states: { 
 
     hover: { 
 
     lineWidthPlus: 0 
 
     } 
 
    }, 
 
    showInLegend: true, 
 
    data: [{ 
 
     y: 0.21 
 
    }, { 
 
     y: 0.21 
 
    }, { 
 
     y: 0.24 
 
    }], 
 
    dataLabels: { 
 
     enabled: false 
 
    } 
 
    }], 
 
    credits: { 
 
    enabled: false 
 
    } 
 
})
<script src="https://code.highcharts.com/highcharts.js"></script> 
 
<script src="https://code.highcharts.com/highcharts-more.js"></script> 
 
<script src="https://code.highcharts.com/modules/exporting.js"></script> 
 

 
<div id="container" style="width: 600px; height: 300px; margin: 0 auto"></div>

+0

這不完全是。散點是第一系列點的50%,因此它們不能正確顯示。前兩個分散點低於他們應該;第三點比它應該高。 –

+0

如果加分:0,最大:1分散,那就起作用!這是:yAxis:{text:null}, labels:{enabled:false}, gridLineWidth:0, reversedStacks:false },{title:{text:null},labels:{enabled :false},gridLineWidth:0,reversedStacks:false,min:0,max:1}], –