1.1.1 • Published 4 years ago

ngx-bucket-echarts-lib v1.1.1

Weekly downloads
72
License
-
Repository
-
Last release
4 years ago

NgxEchartsLib

对echart进行了封装,拥有默认主题可修改主题等

使用说明

安装

npm i ngx-bucket-echarts-lib

内容介绍

关于本插件的所有暴露属性,方法指令。

暴露内容说明类型
NgxEchartsLibModuleModule类导出Module
ngxeCharts基础chart图指令Directive
ngxeChartSimplify简化chart图指令,用于缩略图的显示完美支持line,bar其他类型图表只能正常显示,对数据进行简化Directive
WordCloudChart用于创建词云图的创建类Class
ChartChart的Interfa定义接口,类型规范,可以应用于数据规范Interface

引入

import { NgModule } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import { AppRoutingModule } from './app.routing';

import { NgxEchartsLibModule } from 'ngx-bucket-echarts-lib';

import { AppComponent } from './app.component';

@NgModule({
  declarations: [
    AppComponent
  ],
  imports: [
    BrowserModule,
    AppRoutingModule,
    NgxEchartsLibModule.forRoot(),
  ],
  bootstrap: [AppComponent]
})
export class AppModule { }

在HTML中使用

在HTML中加入指令,就可以开始使用本插件,提供的快捷chart图设置

 <div class="chart-box">
  <div class="chart" ngxeCharts (chartClick)="clickChart($event)" (afterChartView)="afterChart($event)" [options]="options" ></div>
</div>
export class EchartLibComponent implements OnInit {
  public options = {
    yAxis: {
        data: ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun']
    },
    series: [{
        data: [820, 932, 901, 934, 1290, 1330, 1320],
        type: 'bar'
    }]
  };
  constructor(
    public chartService: NgxEchartsLibService
  ) {
  }

  ngOnInit() {
    // 可全局统一设置颜色等统一的主题样式传入Chart类别
  
    // this.chartService.initOption({
    //   color: ['#000', '#ff0000', '#ddd', '#333']
    // });
  }

  clickChart(ev: Event) {
    console.log(ev);
  }

  afterChart(chart) {
    chart.on('contextmenu', (e) => {
      console.log(e, 1);
    });
  }
}

Directive【ngxeCharts】

参数

参数说明类型默认值
[options]放入需要修改的echart属性即可{[key: string]: any}-
[widthDifference]宽度回收值,调整图表和容器的容错number0

事件

事件名称说明返回值
(chartClick)放入需要修改的echart属性即可event
(chartMouseover)放入需要修改的echart属性即可event
(afterChartView)chart加载完成后的回调函数Chart

service NgxEchartsLibService

chart图的服务方法

方法名称说明返回值
initOption对主题进行全局设定void

创建字符云

this.cloud = new WordCloudChart({
  sizeRange: [40, 160],
  setData: [
    {
      name: 'Farrah Abraham',
      value: 66
    },
    {
      name: 'asd',
      value: 366
    },
    {
      name: 'qwe',
      value: 136
    },
    {
      name: 'dfg',
      value: 310
    },
    {
      name: 'qfv',
      value: 240
    }
  ]
});

模版正常使用

 <div class="chart-box">
  <div class="chart" ngxeCharts [options]="cloud" ></div>
</div>

new WordCloudChart 接受对象属性

名称说明类型默认值
setData字符云的数据集{value: number, name: string}Array<{value: number, name: string}>[]
color字符颜色string | string[]Famart
sizeRange字符大小区间number[][10, 140]
emphasis设置重点样式同echart.emphasis(请自行查看https://echarts.apache.org/zh/option.html#legend.emphasis)-
fontFamily字体stringsans-serif
fontWeight是否加粗'normal' \ | 'bold' \| 'bolder' \| 'lighter'bold

Directive【ngxeChartSimplify】

仅仅有效支持linebar类型的图表

创建缩略图

用于生成简单的数据取样缩略图表,配置同普通图表的指令

使用在HTML中的区别

其他设置都和基础指令的内容保持一致,扩展属性请查看下面的属性介绍

 <div class="chart-box">
  <div class="chart" ngxeChartSimplify [options]="options" ></div>
</div>

新增属性

名称说明类型默认值
forceNum数据的取样力度 设置0,小于0返回全部的点图样number3

Interface Chart

请参考官方配置手册https://echarts.apache.org/zh/option.html#title

源文件请产考

gitHub https://github.com/BerQin/ngx-libs/blob/master/projects/ngx-bucket-echarts-lib/src/lib/chart-libs/chart.ts

1.1.1

4 years ago

1.1.0

4 years ago

1.0.5

4 years ago

1.0.4

4 years ago

1.0.2

4 years ago

1.0.3

4 years ago

1.0.1

4 years ago

1.0.0

4 years ago

0.1.0

4 years ago

0.0.9

4 years ago

0.0.8

4 years ago

0.0.7

4 years ago

0.0.3

4 years ago

0.0.5

4 years ago

0.0.4

4 years ago

0.0.6

4 years ago

0.0.2

4 years ago

0.0.1

4 years ago