高图表选项背景颜色:"透明"在IE 8上显示黑色



Highcharts图表选项backgroundColor:'transparent'IE 8上显示黑色

histogram = new Highcharts.Chart({
            chart: { renderTo: 'histogram', defaultSeriesType: 'bar',
                     backgroundColor:'transparent'
            }

这在I.E 9和其他人上工作得很好,但在ie8和Safari上失败了,有人知道为什么吗?

你能试试这个吗-

backgroundColor: null

参见:jsfiddle

试试这个解决方案:

histogram = new Highcharts.Chart({
                chart: { renderTo: 'histogram', defaultSeriesType: 'bar',
                         backgroundColor:'rgba(255, 255, 255, 0.0)'
                }

我在Highcharts中发现了这个:

TRACKER_FILL的经验最小不透明度

  • IE6: 0.002
  • IE7: 0.002
  • IE8: 0.002
  • IE9: 0.00000000001(无限制)
  • IE10: 0.0001(仅限出口)
  • FF: 0.00000000001(无限制)
  • 铬:0.000001
  • Safari: 0.000001
  • Opera: 0.00000000001(无限制)

TRACKER_FILL = 'rgba(192,192,192,' + (hasSVG ?0.0001: 0.002) + ')'

所以你可以将图表背景色设置为'rgba(255,255,255,0.002)',它可以在大多数重要的浏览器中运行。

backgroundColor: 'transparent'也可以工作,如果你需要类型安全

你应该这样做:

.highcharts-background {
   fill: transparent;
}

文档

完整的示例:

Highcharts.chart('container', {
    chart: {
        type: 'line',
        styledMode: true
    },
    title: {
        text: 'Chart border and background by CSS'
    },
    xAxis: {
        categories: ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec']
    },
    legend: {
        layout: 'vertical',
        floating: true,
        align: 'left',
        x: 100,
        verticalAlign: 'top',
        y: 70
    },
    series: [{
        data: [29.9, 71.5, 106.4, 129.2, 144.0, 176.0, 135.6, 148.5, 216.4, 194.1, 95.6, 54.4]
    }]
});
@import "https://code.highcharts.com/css/highcharts.css";
.highcharts-background {
    fill: #efefef;
    stroke: #a4edba;
    stroke-width: 2px;
}
<script src="https://code.highcharts.com/highcharts.js"></script>
<script src="https://code.highcharts.com/modules/exporting.js"></script>
<div id="container" style="height: 400px"></div>

如果您可以访问highcharts.js文件,请转到backgroundColor行(大约479)并更改backgroundColor:"rgba(255, 255, 255, 0)"行。它将改变所有的图表背景为透明

也许你不得不写

filter:0 !important;
backgroundColor:'rgba(255, 255, 255, 0.0)',

相关内容

最新更新