Highchart子弹图plotBackground颜色始终可见

问题描述 投票:0回答:1

所以我设置了一个在最新的高图cdn上运行的子弹图。

https://codepen.io/anon/pen/GzBGbm?&editable=true

Highcharts.setOptions({
  chart: {
    inverted: true,
    marginLeft: 135,
    type: 'bullet',
    backgroundColor: 'red',
    plotBackgroundColor: 'yellow'
  },
  title: {
    text: null
  },
  legend: {
    enabled: false
  },
  xAxis:{
     lineWidth: 0,
     tickWidth:0,
     minorGridLineWidth: 0,
        gridLineWidth: 0,
  },
  yAxis: {
    gridLineWidth: 0,
    minorGridLineWidth: 0,
    tickWidth: 0,
    tickLength: 0,
  },
  plotOptions: {
    series: {
      pointPadding: 0.25,
      borderWidth: 0,
      color: '#000',
      targetOptions: {
        width: '200%'
      }
    }
  },
  credits: {
    enabled: false
  },
  exporting: {
    enabled: false
  }
});

Highcharts.chart('container1', {
  chart: {
    marginTop: 40
  },
  title: {
    text: '2017 YTD'
  },
  xAxis: {
    categories: ['<span class="hc-cat-title">Revenue</span><br/>U.S. $ (1,000s)']
  },
  yAxis: {
    plotBands: [{
      from: 0,
      to: 151,
      color: '#666'
    }, {
      from: 150,
      to: 226,
      color: '#999'
    }, {
      from: 225,
      to: 302,
      color: '#bbb'
    }],
    title: null
  },
  series: [{
    data: [{
      y: 275,
      target: 250
    }]
  }],
  tooltip: {
    pointFormat: '<b>{point.y}</b> (with target at {point.target})'
  }
});

此子弹图具有绘图和全局背景颜色(分别为黄色和红色)

1)为什么我仍然会在下面突出显示的区域中看到情节背景颜色?

2)尽管我目前的配置,我仍然看到xAxis线上仍然是棕色(带阴影的黑暗?) - 如何摆脱这个?

enter image description here

javascript highcharts
1个回答
0
投票

您可以通过将chart.plotBorderWidth = 2chart.plotBorderColor设置为与chart.backgroundColor相同的颜色来摆脱这个黄色边框。检查下面发布的演示和代码。

码:

Highcharts.setOptions({
  chart: {
    inverted: true,
    marginLeft: 135,
    type: 'bullet',
    backgroundColor: 'red',
    plotBackgroundColor: 'yellow',
    plotBorderWidth: 2,
    plotBorderColor: 'red'
  },
  title: {
    text: null
  },
  legend: {
    enabled: false
  },
  xAxis:{
     lineWidth: 0,
     tickWidth:0,
     minorGridLineWidth: 0,
        gridLineWidth: 0,
  },
  yAxis: {
    gridLineWidth: 0,
    minorGridLineWidth: 0,
    tickWidth: 0,
    tickLength: 0,
  },
  plotOptions: {
    series: {
      pointPadding: 0.25,
      borderWidth: 0,
      color: '#000',
      targetOptions: {
        width: '200%'
      }
    }
  },
  credits: {
    enabled: false
  },
  exporting: {
    enabled: false
  }
});

Highcharts.chart('container1', {
  chart: {
    marginTop: 40
  },
  title: {
    text: '2017 YTD'
  },
  xAxis: {
    categories: ['<span class="hc-cat-title">Revenue</span><br/>U.S. $ (1,000s)']
  },
  yAxis: {
    plotBands: [{
      from: 0,
      to: 151,
      color: '#666'
    }, {
      from: 150,
      to: 226,
      color: '#999'
    }, {
      from: 225,
      to: 302,
      color: '#bbb'
    }],
    title: null
  },
  series: [{
    data: [{
      y: 275,
      target: 250
    }]
  }],
  tooltip: {
    pointFormat: '<b>{point.y}</b> (with target at {point.target})'
  }
});
#container1 {
    max-width: 800px;
    height: 115px;
    margin: 1em auto;
}
#container2, #container3 {
    max-width: 800px;
    height: 85px;
    margin: 1em auto;
}
.hc-cat-title {
  font-size: 13px;
  font-weight: bold;
}
<script src="https://code.highcharts.com/highcharts.js"></script>
<script src="https://code.highcharts.com/modules/bullet.js"></script>
<div id="container1"></div>

演示:

© www.soinside.com 2019 - 2024. All rights reserved.