css - 在 Highchart 中为箱形图的每个部分设置单独的颜色

标签 css highcharts

我想要不同颜色的盒子顶部和底部,以及每个盒子(区域)的不同颜色的 mustache 顶部和底部。 但是盒子里的所有线条都是相同的颜色(红色)并且 mustache 的顶部和底部是相同的颜色(绿色)

带有重现步骤的现场演示

 Highcharts.chart('container', {

        chart: {
            type: 'boxplot'
        },

        title: {
            text: 'All Patients'
        },

        legend: {
            enabled: true
        },

        xAxis: {
            categories: ['Asia Pacific', 'Europe', 'Latin America', 'North America', 'SWAC'],
            title: {
                text: '      '
            }
        },

        yAxis: {
            title: {
                text: 'Annual Center Volume 2016'
            },
            tickInterval: 5,
            min: 0,
            max: 75
            //plotLines: [{
            //    value: 932,
            //    color: 'red',
            //    width: 1,
            //    label: {
            //        text: 'Theoretical mean: 932',
            //        align: 'center',
            //        style: {
            //            color: 'gray'
            //        }
            //    }
            //}]
        },
        plotOptions: {
            boxplot: {
                fillColor: '#F0F0E0',
                lineWidth: 2,
                upperQuartileColor: 'green',
                lowerQuartileColor: 'green',
                medianColor: '#0C5DA5',
                medianWidth: 3,
                stemColor: '#A63400',
                stemDashStyle: 'solid',
                stemWidth: 1,
                whiskerColor: '#3D9200',
                whiskerLength: '20%',
                whiskerWidth: 3                 
            }
        },
        series: [{
            name: 'Region Runs',
            showInLegend: false,
            color: 'red',
            data: [
                [2, 4, 18, 43, 53],
                [5, 9, 16.5, 32, 52],
                [1, 3, 6, 11.5, 21],
                [3, 9, 20, 38, 73],
                [1, 2, 8, 16, 20]
            ],
            tooltip: {
                headerFormat: '<em>Experiment No {point.key}</em><br/>'
            }
        },
        {
            name: '75th Percentile',
            type: 'line', 
            color: 'red',
            marker: {
                symbol: 'square'
            },
            
        },
        {
            name: 'Median',
            type: 'line',
            color:'#0C5DA5',
            marker: {
                symbol: 'square'
            },
            
        },
        {
            name: '25th Percentile',
            type: 'line', 
            color: 'red',
            marker: {
                symbol: 'square'
            },
            
        },
        {
            name: '90th percentile',
            type: 'line',
            color: '#3D9200',
            marker: {
                symbol: 'square'
            },
            
        },{
            name: '10th percentile',
            type: 'line',
            color: '#3D9200',
            marker: {
                symbol: 'square'
            },
            
        }
        ]

    });
 <script src="https://code.highcharts.com/highcharts.js"></script>
        <script src="https://code.highcharts.com/highcharts-3d.js"></script>
        <script src="https://code.highcharts.com/modules/exporting.js"></script>
        <script src="https://code.highcharts.com/highcharts-more.js"></script>
        <script src="https://code.highcharts.com/modules/exporting.js"></script>

Box Plot Charts -->
  <div id="pdfContentHolder" style="margin:auto; width: 720px; height: 800px;">
       <div id="container" style="min-width: 310px; height: 400px; max-width: 800px; margin: 0 auto" >
                
       </div>
  </div>

https://jsfiddle.net/hew8nq5u/

提前谢谢大家!

最佳答案

目前在 Highcharts 中不可能有不同颜色的框底部和顶部。与顶部和底部的晶须相同。以下是来自 github issue ( https://github.com/highcharts/highcharts/issues/6796 ) 的解释和增强建议:

Currently each box is a single SVG shape and a border is applied by stroke parameter which cannot be "separated" for smaller edges. As a result, you can apply only single color.

Your goal requires a rebuild core of boxplot, so we cannot threat it as a bug, but feature request.

关于css - 在 Highchart 中为箱形图的每个部分设置单独的颜色,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44388567/

相关文章:

javascript - 使用 labels.formatter 在 x 轴上打印目标标签

javascript - 如何使用 jquery-ui-1.9.2.custom 仅在按钮的左侧添加 border-corner-radius?

html - 100% 不等于 100%?

javascript - 使用 ngClass 更改部分 CSS 类

javascript - Highchart 在图表底部绘制与轴对齐的行

javascript - 使 Highcharts 边框颜色与柱形图上的背景颜色匹配

highcharts - Highchart 饼图 - 设置 useHTML=true 时无法选择数据标签

Highcharts:确保 y 轴 0 值位于图表底部

css - 在移动响应式网页设计中放大和缩小图像的首选方式是什么?

jquery - CSS 文本转换 HTML 错误,Jquery,SQL