2

如何更改 angular2-highcharts 中的背景颜色?我有我的组件:

chart: any;
saveChart(chart) {
     this.chart = chart;
}

  constructor(
private eventManager: EventManager,
private locationService: LocationService,
private route: ActivatedRoute,
private alertService: AlertService

) {

this.options = {
  title: { text: 'Senaste dygnet' },
  xAxis: {
    type: 'datetime',

    title: {
      text: 'Tid'
    }
  },
  yAxis: {
    title: {
      text: 'Temperatur'
    }
  },
  series: [{
     name: 'Vattentemperatur',
    data: []
  }]
};

}

模板:

  <chart [options]="options"  (load)="saveChart($event.context)"></chart>

当我这样做时。chart.backgroundColor = "#000000"; 什么都没发生。

4

2 回答 2

0
chart: {
    "events": {
        "drilldown": drillDownCallBack
    },
    "plotBackgroundColor": "black",
    "plotBorderWidth": null,
    "plotShadow": false,
    "type": "pie"
}

您可以通过"plotBackgroundColor": "black", 作为背景颜色。这是一个例子检查这个

于 2017-06-21T16:51:03.063 回答
0

我从同事那里得到了一些帮助,现在这对我有用。

saveChart(chart) {
     this.chart = chart;
     this.chart.chartBackground.css({
      color: 'rgba(225, 225, 225, 0.7)',
      fontSize: '16px'
    });
}
于 2017-06-21T13:11:27.223 回答