@bitblit/ratchet-echarts 4.0.115-alpha → 4.0.119-alpha

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,4 +1,4 @@
1
- import { BuildInformation } from '@bitblit/ratchet-common/lib/build/build-information.js';
1
+ import { BuildInformation } from '@bitblit/ratchet-common';
2
2
  export declare class RatchetEchartsInfo {
3
3
  private constructor();
4
4
  static buildInformation(): BuildInformation;
@@ -1,4 +1,4 @@
1
- /// <reference types="node" resolution-mode="require"/>
1
+ /// <reference types="node" />
2
2
  import { EChartsOption } from 'echarts';
3
3
  import { Canvas } from 'canvas';
4
4
  import { EChartCanvasConfig } from './echart-canvas-config.js';
package/lib/index.d.ts CHANGED
@@ -1 +1,3 @@
1
- export {};
1
+ export * from './build/ratchet-echarts-info.js';
2
+ export * from './common/echart-canvas-config.js';
3
+ export * from './common/echart-ratchet.js';
package/lib/index.mjs ADDED
@@ -0,0 +1,2 @@
1
+ import*as r from"echarts";import{Canvas as t}from"canvas";import e from"fs";class n{constructor(){}static buildInformation(){return{version:"LOCAL-SNAPSHOT",hash:"LOCAL-HASH",branch:"LOCAL-BRANCH",tag:"LOCAL-TAG",timeBuiltISO:"LOCAL-TIME-ISO",notes:"LOCAL-NOTES"}}}class a{static async renderChartUsingProvidedCanvas(t,e){if(!t)throw new Error("You must supply an opts parameter");if(!e)throw new Error("You must supply an canvas parameter");let n=null;t.animation=!1;const a=e;return r.init(a).setOption(t),n=e.toBuffer(),n}static async renderChart(r,e){if(!r)throw new Error("You must supply an opts parameter");if(!e)throw new Error("You must supply an config parameter");const n=new t(e.width,e.height);return await this.renderChartUsingProvidedCanvas(r,n)}static async renderChartToPngFile(r,t,n){if(!t)throw new Error("You must supply an opts parameter");if(!n)throw new Error("You must supply an config parameter");if(!r||0===r.trim().length)throw new Error("You must supply a non-empty filename parameter");if(!r.toLowerCase().endsWith(".png"))throw new Error("Your filename should end with .png - this generates a png file");const a=await this.renderChart(t,n);return e.writeFileSync(r,a),a}}export{a as EChartRatchet,n as RatchetEchartsInfo};
2
+ //# sourceMappingURL=index.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.mjs","sources":["../src/build/ratchet-echarts-info.ts","../src/common/echart-ratchet.ts"],"sourcesContent":[null,null],"names":["RatchetEchartsInfo","constructor","static","version","hash","branch","tag","timeBuiltISO","notes","EChartRatchet","opt","canvas","Error","rval","animation","canvasHtml","echarts","init","setOption","toBuffer","opts","config","Canvas","width","height","this","renderChartUsingProvidedCanvas","filename","trim","length","toLowerCase","endsWith","renderChart","fs","writeFileSync"],"mappings":"kFAEaA,EAGXC,cAAwB,CAEjBC,0BASL,MAR8B,CAC5BC,QAAS,iBACTC,KAAM,aACNC,OAAQ,eACRC,IAAK,YACLC,aAAc,iBACdC,MAAO,cAGV,QCXUC,EACJP,4CAA4CQ,EAAoBC,GACrE,IAAKD,EACH,MAAM,IAAIE,MAAM,qCAElB,IAAKD,EACH,MAAM,IAAIC,MAAM,uCAElB,IAAIC,EAAe,KAEnBH,EAAII,WAAY,EAChB,MAAMC,EAA0BJ,EAMhC,OAHuBK,EAAQC,KAAKF,GAC9BG,UAAUR,GAChBG,EAAOF,EAAOQ,WACPN,CACR,CAEMX,yBAAyBkB,EAAqBC,GACnD,IAAKD,EACH,MAAM,IAAIR,MAAM,qCAElB,IAAKS,EACH,MAAM,IAAIT,MAAM,uCAElB,MAAMD,EAAiB,IAAIW,EAAOD,EAAOE,MAAOF,EAAOG,QAGvD,aAF2BC,KAAKC,+BAA+BN,EAAMT,EAGtE,CAEMT,kCAAkCyB,EAAkBP,EAAqBC,GAC9E,IAAKD,EACH,MAAM,IAAIR,MAAM,qCAElB,IAAKS,EACH,MAAM,IAAIT,MAAM,uCAElB,IAAKe,GAAuC,IAA3BA,EAASC,OAAOC,OAC/B,MAAM,IAAIjB,MAAM,kDAElB,IAAKe,EAASG,cAAcC,SAAS,QACnC,MAAM,IAAInB,MAAM,kEAElB,MAAMC,QAAqBY,KAAKO,YAAYZ,EAAMC,GAGlD,OAFAY,EAAGC,cAAcP,EAAUd,GAEpBA,CACR"}
package/package.json CHANGED
@@ -1,13 +1,18 @@
1
1
  {
2
2
  "name": "@bitblit/ratchet-echarts",
3
- "version": "4.0.115-alpha",
3
+ "version": "4.0.119-alpha",
4
4
  "description": "Library for using echarts on Node",
5
5
  "type": "module",
6
- "module": "index.js",
7
6
  "files": [
8
7
  "lib/*",
9
8
  "bin/*"
10
9
  ],
10
+ "exports": {
11
+ ".": {
12
+ "types": "./lib/index.d.ts",
13
+ "import": "./lib/index.mjs"
14
+ }
15
+ },
11
16
  "contributors": [
12
17
  "Christopher Weiss <bitblit@gmail.com>"
13
18
  ],
@@ -28,9 +33,9 @@
28
33
  "test": "cross-env NODE_OPTIONS=--experimental-vm-modules jest",
29
34
  "lint": "eslint src/**/*.ts",
30
35
  "lint-fix": "eslint --fix src/**/*.ts",
31
- "__generate-barrels": "barrelsby -q --delete -d src -e .*\\.spec\\.ts",
32
- "__build": "yarn run generate-barrels && tsc",
33
- "build": "tsc"
36
+ "generate-barrels": "barrelsby -q --delete -d src -e .*\\.spec\\.ts && sed -i 's/\\x27;/.js\\x27;/' src/index.ts",
37
+ "build": "yarn clean && yarn generate-barrels && shx mkdir -p lib/native && rollup -c rollup.config.js",
38
+ "force-build": "tsc --build --force"
34
39
  },
35
40
  "license": "Apache-2.0",
36
41
  "dependencies": {
@@ -38,6 +43,6 @@
38
43
  "echarts": "5.4.2"
39
44
  },
40
45
  "devDependencies": {
41
- "@bitblit/ratchet-common": "4.0.115-alpha"
46
+ "@bitblit/ratchet-common": "4.0.119-alpha"
42
47
  }
43
48
  }
@@ -1,14 +0,0 @@
1
- export class RatchetEchartsInfo {
2
- constructor() { }
3
- static buildInformation() {
4
- const val = {
5
- version: 'LOCAL-SNAPSHOT',
6
- hash: 'LOCAL-HASH',
7
- branch: 'LOCAL-BRANCH',
8
- tag: 'LOCAL-TAG',
9
- timeBuiltISO: 'LOCAL-TIME-ISO',
10
- notes: 'LOCAL-NOTES',
11
- };
12
- return val;
13
- }
14
- }
@@ -1 +0,0 @@
1
- export {};
@@ -1,48 +0,0 @@
1
- import echarts from 'echarts';
2
- import { Canvas } from 'canvas';
3
- import fs from 'fs';
4
- export class EChartRatchet {
5
- static async renderChartUsingProvidedCanvas(opt, canvas) {
6
- if (!opt) {
7
- throw new Error('You must supply an opts parameter');
8
- }
9
- if (!canvas) {
10
- throw new Error('You must supply an canvas parameter');
11
- }
12
- let rval = null;
13
- opt.animation = false;
14
- const canvasHtml = canvas;
15
- const chart = echarts.init(canvasHtml);
16
- chart.setOption(opt);
17
- rval = canvas.toBuffer();
18
- return rval;
19
- }
20
- static async renderChart(opts, config) {
21
- if (!opts) {
22
- throw new Error('You must supply an opts parameter');
23
- }
24
- if (!config) {
25
- throw new Error('You must supply an config parameter');
26
- }
27
- const canvas = new Canvas(config.width, config.height);
28
- const rval = await this.renderChartUsingProvidedCanvas(opts, canvas);
29
- return rval;
30
- }
31
- static async renderChartToPngFile(filename, opts, config) {
32
- if (!opts) {
33
- throw new Error('You must supply an opts parameter');
34
- }
35
- if (!config) {
36
- throw new Error('You must supply an config parameter');
37
- }
38
- if (!filename || filename.trim().length === 0) {
39
- throw new Error('You must supply a non-empty filename parameter');
40
- }
41
- if (!filename.toLowerCase().endsWith('.png')) {
42
- throw new Error('Your filename should end with .png - this generates a png file');
43
- }
44
- const rval = await this.renderChart(opts, config);
45
- fs.writeFileSync(filename, rval);
46
- return rval;
47
- }
48
- }
@@ -1,107 +0,0 @@
1
- import { EChartRatchet } from '../common/echart-ratchet.js';
2
- const options = {
3
- title: {
4
- text: 'Stacked Area Chart',
5
- },
6
- tooltip: {
7
- trigger: 'axis',
8
- axisPointer: {
9
- type: 'cross',
10
- label: {
11
- backgroundColor: '#6a7985',
12
- },
13
- },
14
- },
15
- legend: {
16
- data: ['Email', 'Union Ads', 'Video Ads', 'Direct', 'Search Engine'],
17
- },
18
- toolbox: {
19
- feature: {
20
- saveAsImage: {},
21
- },
22
- },
23
- grid: {
24
- left: '3%',
25
- right: '4%',
26
- bottom: '3%',
27
- containLabel: true,
28
- },
29
- xAxis: [
30
- {
31
- type: 'category',
32
- boundaryGap: false,
33
- data: ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun'],
34
- },
35
- ],
36
- yAxis: [
37
- {
38
- type: 'value',
39
- },
40
- ],
41
- series: [
42
- {
43
- name: 'Email',
44
- type: 'line',
45
- stack: 'Total',
46
- areaStyle: {},
47
- emphasis: {
48
- focus: 'series',
49
- },
50
- data: [120, 132, 101, 134, 90, 230, 210],
51
- },
52
- {
53
- name: 'Union Ads',
54
- type: 'line',
55
- stack: 'Total',
56
- areaStyle: {},
57
- emphasis: {
58
- focus: 'series',
59
- },
60
- data: [220, 182, 191, 234, 290, 330, 310],
61
- },
62
- {
63
- name: 'Video Ads',
64
- type: 'line',
65
- stack: 'Total',
66
- areaStyle: {},
67
- emphasis: {
68
- focus: 'series',
69
- },
70
- data: [150, 232, 201, 154, 190, 330, 410],
71
- },
72
- {
73
- name: 'Direct',
74
- type: 'line',
75
- stack: 'Total',
76
- areaStyle: {},
77
- emphasis: {
78
- focus: 'series',
79
- },
80
- data: [320, 332, 301, 334, 390, 330, 320],
81
- },
82
- {
83
- name: 'Search Engine',
84
- type: 'line',
85
- stack: 'Total',
86
- label: {
87
- show: true,
88
- position: 'top',
89
- },
90
- areaStyle: {},
91
- emphasis: {
92
- focus: 'series',
93
- },
94
- data: [820, 932, 901, 934, 1290, 1330, 1320],
95
- },
96
- ],
97
- };
98
- describe('#areaChart', function () {
99
- it('should generate the chart', async () => {
100
- const data = await EChartRatchet.renderChart(options, {
101
- width: 1000,
102
- height: 500,
103
- });
104
- expect(data.length).toBeGreaterThan(50_000);
105
- expect(data.length).toBeLessThan(60_000);
106
- });
107
- });
@@ -1,69 +0,0 @@
1
- import { EChartRatchet } from '../common/echart-ratchet.js';
2
- const labelRight = {
3
- position: 'right',
4
- };
5
- const options = {
6
- title: {
7
- text: 'Bar Chart with Negative Value',
8
- },
9
- tooltip: {
10
- trigger: 'axis',
11
- axisPointer: {
12
- type: 'shadow',
13
- },
14
- },
15
- grid: {
16
- top: 80,
17
- bottom: 30,
18
- },
19
- xAxis: {
20
- type: 'value',
21
- position: 'top',
22
- splitLine: {
23
- lineStyle: {
24
- type: 'dashed',
25
- },
26
- },
27
- },
28
- yAxis: {
29
- type: 'category',
30
- axisLine: { show: false },
31
- axisLabel: { show: false },
32
- axisTick: { show: false },
33
- splitLine: { show: false },
34
- data: ['ten', 'nine', 'eight', 'seven', 'six', 'five', 'four', 'three', 'two', 'one'],
35
- },
36
- series: [
37
- {
38
- name: 'Cost',
39
- type: 'bar',
40
- stack: 'Total',
41
- label: {
42
- show: true,
43
- formatter: '{b}',
44
- },
45
- data: [
46
- { value: -0.07, label: labelRight },
47
- { value: -0.09, label: labelRight },
48
- 0.2,
49
- 0.44,
50
- { value: -0.23, label: labelRight },
51
- 0.08,
52
- { value: -0.17, label: labelRight },
53
- 0.47,
54
- { value: -0.36, label: labelRight },
55
- 0.18,
56
- ],
57
- },
58
- ],
59
- };
60
- describe('#simpleBarChart', function () {
61
- it('should generate the chart', async () => {
62
- const data = await EChartRatchet.renderChartToPngFile('test.png', options, {
63
- width: 1000,
64
- height: 500,
65
- });
66
- expect(data.length).toBeGreaterThan(15_000);
67
- expect(data.length).toBeLessThan(20_000);
68
- });
69
- });
@@ -1,165 +0,0 @@
1
- import { EChartRatchet } from '../common/echart-ratchet.js';
2
- import echarts from 'echarts';
3
- const data = [
4
- [
5
- [28604, 77, 17096869, 'Australia', 1990],
6
- [31163, 77.4, 27662440, 'Canada', 1990],
7
- [1516, 68, 1154605773, 'China', 1990],
8
- [13670, 74.7, 10582082, 'Cuba', 1990],
9
- [28599, 75, 4986705, 'Finland', 1990],
10
- [29476, 77.1, 56943299, 'France', 1990],
11
- [31476, 75.4, 78958237, 'Germany', 1990],
12
- [28666, 78.1, 254830, 'Iceland', 1990],
13
- [1777, 57.7, 870601776, 'India', 1990],
14
- [29550, 79.1, 122249285, 'Japan', 1990],
15
- [2076, 67.9, 20194354, 'North Korea', 1990],
16
- [12087, 72, 42972254, 'South Korea', 1990],
17
- [24021, 75.4, 3397534, 'New Zealand', 1990],
18
- [43296, 76.8, 4240375, 'Norway', 1990],
19
- [10088, 70.8, 38195258, 'Poland', 1990],
20
- [19349, 69.6, 147568552, 'Russia', 1990],
21
- [10670, 67.3, 53994605, 'Turkey', 1990],
22
- [26424, 75.7, 57110117, 'United Kingdom', 1990],
23
- [37062, 75.4, 252847810, 'United States', 1990],
24
- ],
25
- [
26
- [44056, 81.8, 23968973, 'Australia', 2015],
27
- [43294, 81.7, 35939927, 'Canada', 2015],
28
- [13334, 76.9, 1376048943, 'China', 2015],
29
- [21291, 78.5, 11389562, 'Cuba', 2015],
30
- [38923, 80.8, 5503457, 'Finland', 2015],
31
- [37599, 81.9, 64395345, 'France', 2015],
32
- [44053, 81.1, 80688545, 'Germany', 2015],
33
- [42182, 82.8, 329425, 'Iceland', 2015],
34
- [5903, 66.8, 1311050527, 'India', 2015],
35
- [36162, 83.5, 126573481, 'Japan', 2015],
36
- [1390, 71.4, 25155317, 'North Korea', 2015],
37
- [34644, 80.7, 50293439, 'South Korea', 2015],
38
- [34186, 80.6, 4528526, 'New Zealand', 2015],
39
- [64304, 81.6, 5210967, 'Norway', 2015],
40
- [24787, 77.3, 38611794, 'Poland', 2015],
41
- [23038, 73.13, 143456918, 'Russia', 2015],
42
- [19360, 76.5, 78665830, 'Turkey', 2015],
43
- [38225, 81.4, 64715810, 'United Kingdom', 2015],
44
- [53354, 79.1, 321773631, 'United States', 2015],
45
- ],
46
- ];
47
- const options = {
48
- backgroundColor: new echarts.graphic.RadialGradient(0.3, 0.3, 0.8, [
49
- {
50
- offset: 0,
51
- color: '#f7f8fa',
52
- },
53
- {
54
- offset: 1,
55
- color: '#cdd0d5',
56
- },
57
- ]),
58
- title: {
59
- text: 'Life Expectancy and GDP by Country',
60
- left: '5%',
61
- top: '3%',
62
- },
63
- legend: {
64
- right: '10%',
65
- top: '3%',
66
- data: ['1990', '2015'],
67
- },
68
- grid: {
69
- left: '8%',
70
- top: '10%',
71
- },
72
- xAxis: {
73
- splitLine: {
74
- lineStyle: {
75
- type: 'dashed',
76
- },
77
- },
78
- },
79
- yAxis: {
80
- splitLine: {
81
- lineStyle: {
82
- type: 'dashed',
83
- },
84
- },
85
- scale: true,
86
- },
87
- series: [
88
- {
89
- name: '1990',
90
- data: data[0],
91
- type: 'scatter',
92
- symbolSize: function (data) {
93
- return Math.sqrt(data[2]) / 5e2;
94
- },
95
- emphasis: {
96
- focus: 'series',
97
- label: {
98
- show: true,
99
- formatter: function (param) {
100
- return param.data[3];
101
- },
102
- position: 'top',
103
- },
104
- },
105
- itemStyle: {
106
- shadowBlur: 10,
107
- shadowColor: 'rgba(120, 36, 50, 0.5)',
108
- shadowOffsetY: 5,
109
- color: new echarts.graphic.RadialGradient(0.4, 0.3, 1, [
110
- {
111
- offset: 0,
112
- color: 'rgb(251, 118, 123)',
113
- },
114
- {
115
- offset: 1,
116
- color: 'rgb(204, 46, 72)',
117
- },
118
- ]),
119
- },
120
- },
121
- {
122
- name: '2015',
123
- data: data[1],
124
- type: 'scatter',
125
- symbolSize: function (data) {
126
- return Math.sqrt(data[2]) / 5e2;
127
- },
128
- emphasis: {
129
- focus: 'series',
130
- label: {
131
- show: true,
132
- formatter: function (param) {
133
- return param.data[3];
134
- },
135
- position: 'top',
136
- },
137
- },
138
- itemStyle: {
139
- shadowBlur: 10,
140
- shadowColor: 'rgba(25, 100, 150, 0.5)',
141
- shadowOffsetY: 5,
142
- color: new echarts.graphic.RadialGradient(0.4, 0.3, 1, [
143
- {
144
- offset: 0,
145
- color: 'rgb(129, 227, 238)',
146
- },
147
- {
148
- offset: 1,
149
- color: 'rgb(25, 183, 207)',
150
- },
151
- ]),
152
- },
153
- },
154
- ],
155
- };
156
- describe('#bubbleChart', function () {
157
- it('should generate the chart', async () => {
158
- const data = await EChartRatchet.renderChart(options, {
159
- width: 1000,
160
- height: 500,
161
- });
162
- expect(data.length).toBeGreaterThan(140_000);
163
- expect(data.length).toBeLessThan(150_000);
164
- });
165
- });
@@ -1,72 +0,0 @@
1
- import { EChartRatchet } from '../common/echart-ratchet.js';
2
- const options = {
3
- backgroundColor: '#2c343c',
4
- title: {
5
- text: 'Customized Pie',
6
- left: 'center',
7
- top: 20,
8
- textStyle: {
9
- color: '#ccc',
10
- },
11
- },
12
- tooltip: {
13
- trigger: 'item',
14
- },
15
- visualMap: {
16
- show: false,
17
- min: 80,
18
- max: 600,
19
- inRange: {
20
- colorLightness: [0, 1],
21
- },
22
- },
23
- series: [
24
- {
25
- name: 'Access From',
26
- type: 'pie',
27
- radius: '55%',
28
- center: ['50%', '50%'],
29
- data: [
30
- { value: 335, name: 'Direct' },
31
- { value: 310, name: 'Email' },
32
- { value: 274, name: 'Union Ads' },
33
- { value: 235, name: 'Video Ads' },
34
- { value: 400, name: 'Search Engine' },
35
- ].sort(function (a, b) {
36
- return a.value - b.value;
37
- }),
38
- roseType: 'radius',
39
- label: {
40
- color: 'rgba(255, 255, 255, 0.3)',
41
- },
42
- labelLine: {
43
- lineStyle: {
44
- color: 'rgba(255, 255, 255, 0.3)',
45
- },
46
- smooth: 0.2,
47
- length: 10,
48
- length2: 20,
49
- },
50
- itemStyle: {
51
- color: '#c23531',
52
- shadowBlur: 200,
53
- shadowColor: 'rgba(0, 0, 0, 0.5)',
54
- },
55
- animationType: 'scale',
56
- animationEasing: 'elasticOut',
57
- animationDelay: function (idx) {
58
- return Math.random() * 200;
59
- },
60
- },
61
- ],
62
- };
63
- describe('#pieChart', function () {
64
- it('should generate the chart', async () => {
65
- const data = await EChartRatchet.renderChartToPngFile('test.png', options, {
66
- width: 1000,
67
- height: 500,
68
- });
69
- expect(data.length).toBeGreaterThan(30_000);
70
- expect(data.length).toBeLessThan(40_000);
71
- });
72
- });
@@ -1,31 +0,0 @@
1
- import { EChartRatchet } from '../common/echart-ratchet.js';
2
- const options = {
3
- title: {
4
- text: 'test',
5
- },
6
- tooltip: {},
7
- legend: {
8
- data: ['test'],
9
- },
10
- xAxis: {
11
- data: ['a', 'b', 'c', 'd', 'f', 'g'],
12
- },
13
- yAxis: {},
14
- series: [
15
- {
16
- name: 'test',
17
- type: 'bar',
18
- data: [5, 20, 36, 10, 10, 20],
19
- },
20
- ],
21
- };
22
- describe('#simpleBarChart', function () {
23
- it('should generate the chart', async () => {
24
- const data = await EChartRatchet.renderChart(options, {
25
- width: 1000,
26
- height: 500,
27
- });
28
- expect(data.length).toBeGreaterThan(5_000);
29
- expect(data.length).toBeLessThan(10_000);
30
- });
31
- });
package/lib/index.js DELETED
@@ -1 +0,0 @@
1
- export {};