加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 综合聚焦 > 服务器 > 安全 > 正文

angular2-highcharts用法详解

发布时间:2020-12-17 09:43:46 所属栏目:安全 来源:网络整理
导读:1、 使用npm安装angular2-highcharts npm install angular2-highcharts --save 2、主模块中引入 app.module.ts import {ChartModule} from "angular2-highcharts";...imports: [ ChartModule]... 3、组件中定义图标配置数据,可在highcharts官网查看配置 app

1、 使用npm安装angular2-highcharts

npm install angular2-highcharts --save

2、主模块中引入 app.module.ts

import {ChartModule} from "angular2-highcharts";
...
imports: [
    ChartModule
]
...

3、组件中定义图标配置数据,可在highcharts官网查看配置 app.component.ts

import {Component} from '@angular/core';
@Component({
  selector: 'app-root',templateUrl: './app.component.html'
})
export class AppComponent {
  options:Object;
  constructor() {
    this.options = {
      chart: {
        plotBackgroundColor: null,plotBorderWidth: null,plotShadow: false,type: 'pie'
      },title: {
        text: 'Browser market shares at a specific website,2014'
      },tooltip: {
        pointFormat: '{series.name}: <b>{point.percentage:.1f}%</b>'
      },plotOptions: {
        pie: {
          allowPointSelect: true,cursor: 'pointer',dataLabels: {
            enabled: true,format: '<b>{point.name}</b>: {point.percentage:.1f} %'
          }
        }
      },series: [{
        name: 'Brands',data: [
          { name: 'Microsoft Internet Explorer',y: 56.33 },{ name: 'Chrome',y: 24.03 },{ name: 'Firefox',y: 10.38 },{ name: 'Safari',y: 4.77 },{ name: 'Opera',y: 0.91 },{ name: 'Proprietary or Undetectable',y: 0.2 }
        ]
      }]
    }
  }
}

4、模板中加载图像

<chart [options]="options"></chart>

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读