@fc-plot/ts-graph 0.6.0

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.
package/.editorconfig ADDED
@@ -0,0 +1,16 @@
1
+ # http://editorconfig.org
2
+ root = true
3
+
4
+ [*]
5
+ indent_style = space
6
+ indent_size = 2
7
+ end_of_line = lf
8
+ charset = utf-8
9
+ trim_trailing_whitespace = true
10
+ insert_final_newline = true
11
+
12
+ [*.md]
13
+ trim_trailing_whitespace = false
14
+
15
+ [Makefile]
16
+ indent_style = tab
package/.eslintignore ADDED
@@ -0,0 +1,8 @@
1
+ examples/*
2
+ coverage/*
3
+ tests/*
4
+ dist/*
5
+ webpack.*
6
+ proxy.*
7
+ webpack.compile.config.js
8
+ webpack.dev.config.js
package/.eslintrc ADDED
@@ -0,0 +1,60 @@
1
+ {
2
+ "extends": [
3
+ "airbnb-typescript"
4
+ ],
5
+ "parser": "@typescript-eslint/parser",
6
+ "parserOptions": {
7
+ "ecmaFeatures": {
8
+ "generators": true,
9
+ "classes": true
10
+ }
11
+ },
12
+ "env": {
13
+ "browser": true,
14
+ "node": true,
15
+ "mocha": true,
16
+ "jest": true
17
+ },
18
+ "rules": {
19
+ "arrow-body-style": 1,
20
+ "function-paren-newline": [
21
+ 2,
22
+ "consistent"
23
+ ],
24
+ "newline-per-chained-call": 1,
25
+ "object-curly-newline": 1,
26
+ "global-require": 1,
27
+ "max-len": [
28
+ 1,
29
+ 100,
30
+ 2,
31
+ {
32
+ "ignoreUrls": true,
33
+ "ignoreComments": false,
34
+ "ignoreRegExpLiterals": true,
35
+ "ignoreStrings": true,
36
+ "ignoreTemplateLiterals": true
37
+ }
38
+ ],
39
+ "no-param-reassign": 1,
40
+ "import/no-unresolved": 0,
41
+ "import/extensions": "ignorePackages",
42
+ "jsx-a11y/anchor-is-valid": 0,
43
+ "jsx-a11y/click-events-have-key-events": 0,
44
+ "jsx-a11y/no-static-element-interactions": 0,
45
+ "jsx-a11y/no-noninteractive-element-interactions": 0,
46
+ "react/jsx-first-prop-new-line": 0,
47
+ "react/jsx-max-props-per-line": [
48
+ 2,
49
+ {
50
+ "maximum": 3
51
+ }
52
+ ],
53
+ "react/jsx-closing-bracket-location": [
54
+ 0,
55
+ "after-props"
56
+ ],
57
+ "react/jsx-no-target-blank": 1,
58
+ "react/forbid-prop-types": 1
59
+ }
60
+ }
package/CHANGELOG.md ADDED
File without changes
package/README.md ADDED
@@ -0,0 +1,122 @@
1
+ # ts-graph
2
+
3
+ ---
4
+
5
+ a time series graph using D3.js.
6
+
7
+ ## Install
8
+
9
+ ```sh
10
+ npm i @fc-plot/ts-graph -S
11
+ ```
12
+
13
+ ## Demo
14
+
15
+ ```js
16
+ import { random } from 'lodash';
17
+ import TsGraph from '@fc-plot/ts-graph';
18
+ import '@fc-plot/ts-graph/dist/index.css';
19
+
20
+ function generateSeries(seriesCount = 1000) {
21
+ const series = [];
22
+
23
+ for (let n = 1; n <= seriesCount; n++) {
24
+ const seriesData = [];
25
+ const seriesDataCount = random(99, 100);
26
+
27
+ for (let m = 1; m <= seriesDataCount; m++) {
28
+ seriesData.push({
29
+ timestamp: 1502266250000 + (m * 10000),
30
+ value: random(0, 1000, 3),
31
+ marker: {
32
+ enabled: true,
33
+ radius: 1,
34
+ }
35
+ });
36
+ }
37
+
38
+ series.push({
39
+ name: `serie-${n}`,
40
+ data: seriesData,
41
+ });
42
+ }
43
+
44
+ return series;
45
+ }
46
+
47
+ new TsGraph({
48
+ timestamp: 'x',
49
+ xkey: 'timestamp',
50
+ ykey: 'value',
51
+ chart: {
52
+ renderTo: document.getElementById(`content`),
53
+ },
54
+ series: generateSeries(),
55
+ })
56
+ ```
57
+
58
+ ## Options
59
+
60
+ ```js
61
+ const defaultOptions = {
62
+ ratio: window.devicePixelRatio || 1,
63
+ xkey: 0, // time keyName
64
+ ykey: 1, // value keyName
65
+ timestamp: 'x', // timestamp type x: Unix Millisecond, X: Unix
66
+ chart: {
67
+ id: uniqueId('d3-graph-'),
68
+ colors: ['#3399CC', '#CC9933', '#9966CC', '#66CC66', '#CC3333', '#99CCCC', '#CCCC66', '#CC99CC', '#99CC99', '#CC6666', '#336699', '#996633', '#993399', '#339966', '#993333'],
69
+ renderTo: userOptions.chart.renderTo,
70
+ width: userOptions.chart.renderTo.offsetWidth,
71
+ height: userOptions.chart.renderTo.offsetHeight || 350,
72
+ marginTop: 10,
73
+ marginRight: 10,
74
+ marginBottom: 10,
75
+ marginLeft: 10,
76
+ },
77
+ xAxis: {
78
+ lineColor: '#ccc',
79
+ lineWidth: 1,
80
+ tickLength: 5,
81
+ tickpadding: 5,
82
+ tickColor: '#ccc',
83
+ labels: {
84
+ color: '#999',
85
+ fontSize: 11,
86
+ },
87
+ },
88
+ yAxis: {
89
+ lineColor: '#ccc',
90
+ lineWidth: 1,
91
+ tickLength: 5,
92
+ tickpadding: 5,
93
+ tickColor: '#ccc',
94
+ gridLineColor: '#efefef',
95
+ labels: {
96
+ color: '#999',
97
+ fontSize: 11,
98
+ style: {
99
+ fontSize: 11,
100
+ color: '#999',
101
+ },
102
+ },
103
+ plotLines: [{
104
+ value: 100,
105
+ color: 'red',
106
+ }],
107
+ },
108
+ tooltip: {
109
+ shared: true,
110
+ formatter: undefined, // 自定义 tooltip 内容 undefined | (points) => StringOfHTML
111
+ },
112
+ series: [] // { name: string, data: any[] }[],
113
+ fillNull: undefined,
114
+ onZoom: () => {},
115
+ }
116
+ ```
117
+
118
+ ## Api
119
+
120
+ ### update(newOptions)
121
+
122
+ ### destroy
@@ -0,0 +1,58 @@
1
+ .ts-graph-tooltip {
2
+ visibility: hidden;
3
+ position: absolute;
4
+ pointer-events: none;
5
+ width: 100%;
6
+ }
7
+ .ts-graph-tooltip-content {
8
+ font-family: "Lucida Grande", "Lucida Sans Unicode", Arial, Helvetica, sans-serif;
9
+ font-size: 12px;
10
+ position: absolute;
11
+ color: #333333;
12
+ margin-left: 0px;
13
+ margin-top: 0px;
14
+ left: 8px;
15
+ top: 8px;
16
+ background: rgba(255, 255, 255, 0.85);
17
+ border: 1px solid silver;
18
+ border-radius: 3px;
19
+ box-shadow: 1px 1px 1px #888;
20
+ white-space: nowrap;
21
+ padding: 5px;
22
+ }
23
+ .ts-graph-tooltip ul {
24
+ list-style: none;
25
+ margin: 0;
26
+ padding: 0;
27
+ }
28
+ .ts-graph-tooltip ul li {
29
+ table-layout: fixed;
30
+ word-wrap: break-word;
31
+ white-space: normal;
32
+ }
33
+ .ts-graph-zoom {
34
+ position: relative;
35
+ }
36
+ .ts-graph-zoom-marker {
37
+ position: absolute;
38
+ background: rgba(51, 92, 173, 0.25);
39
+ }
40
+ .ts-graph-zoom-resetBtn {
41
+ display: none;
42
+ position: absolute;
43
+ z-index: 1;
44
+ top: 10px;
45
+ right: 10px;
46
+ background: #f7f7f7;
47
+ font-size: 12px;
48
+ text-align: center;
49
+ width: 84px;
50
+ height: 31px;
51
+ line-height: 31px;
52
+ border: 1px solid #ccc;
53
+ cursor: pointer;
54
+ color: #333;
55
+ }
56
+ .ts-graph-zoom-resetBtn:hover {
57
+ background: #e6e6e6;
58
+ }
@@ -0,0 +1,101 @@
1
+ .d3-graph-container {
2
+ user-select: none;
3
+ }
4
+
5
+ .ts-graph-tooltip {
6
+ visibility: hidden;
7
+ position: fixed;
8
+ pointer-events: none;
9
+ user-select: none;
10
+ width: 100%;
11
+ }
12
+ .ts-graph-tooltip-content {
13
+ font-size: 12px;
14
+ font-family: "Lucida Grande", "Lucida Sans Unicode", Arial, Helvetica, sans-serif;
15
+ font-size: 12px;
16
+ white-space: nowrap;
17
+ color: rgb(51, 51, 51);
18
+ margin-left: 0px;
19
+ margin-top: 0px;
20
+ background: rgba(255, 255, 255, 0.85);
21
+ border: 1px solid silver;
22
+ border-radius: 3px;
23
+ box-shadow: 1px 1px 1px #888;
24
+ white-space: nowrap;
25
+ padding: 5px;
26
+ position: fixed;
27
+ z-index: 9999;
28
+ }
29
+ .ts-graph-tooltip ul {
30
+ list-style: none;
31
+ margin: 0;
32
+ padding: 0;
33
+ }
34
+ .ts-graph-tooltip ul li {
35
+ table-layout: fixed;
36
+ word-wrap: break-word;
37
+ white-space: normal;
38
+ }
39
+ .ts-graph-zoom {
40
+ position: relative;
41
+ }
42
+ .ts-graph-legend {
43
+ position: relative;
44
+ padding: 0 10px;
45
+ }
46
+ .ts-graph-legend-item {
47
+ cursor: pointer;
48
+ display: inline-block;
49
+ margin-right: 10px;
50
+ word-break: break-all;
51
+ }
52
+ .ts-graph-legend-item-symbol {
53
+ position: relative;
54
+ display: inline-block;
55
+ vertical-align: middle;
56
+ text-align: center;
57
+ width: 20px;
58
+ height: 20px;;
59
+ margin: 0 5px;
60
+ }
61
+ .ts-graph-legend-item-symbol-line {
62
+ position: absolute;
63
+ display: inline-block;
64
+ width: 20px;
65
+ top: 9px;
66
+ left: 0;
67
+ border-width: 1px;
68
+ border-style: solid;
69
+ }
70
+ .ts-graph-legend-item-symbol-point {
71
+ position: absolute;
72
+ display: inline-block;
73
+ width: 10px;
74
+ height: 10px;
75
+ top: 5px;
76
+ left: 5px;
77
+ border-radius: 10px;
78
+ }
79
+ .ts-graph-zoom-marker {
80
+ position: absolute;
81
+ background: rgba(51,92,173,0.25);
82
+ }
83
+ .ts-graph-zoom-resetBtn {
84
+ display: none;
85
+ position: absolute;
86
+ z-index: 1;
87
+ top: 10px;
88
+ right: 10px;
89
+ background: #f7f7f7;
90
+ font-size: 12px;
91
+ text-align: center;
92
+ width: 84px;
93
+ height: 31px;
94
+ line-height: 31px;
95
+ border: 1px solid #ccc;
96
+ cursor: pointer;
97
+ color: #333;
98
+ }
99
+ .ts-graph-zoom-resetBtn:hover {
100
+ background: #e6e6e6;
101
+ }