@plotdb/chart 0.0.2 → 1.0.3

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.
Files changed (164) hide show
  1. package/README.md +3 -3
  2. package/dist/chart.js +18 -12
  3. package/dist/chart.min.js +1 -1
  4. package/dist/index.css +8 -0
  5. package/dist/index.js +609 -0
  6. package/dist/index.min.css +1 -0
  7. package/dist/index.min.js +1 -0
  8. package/dist/utils/axis.js +6 -0
  9. package/dist/utils/axis.min.js +1 -1
  10. package/package.json +22 -11
  11. package/CHANGELOG.md +0 -11
  12. package/build +0 -39
  13. package/doc/charts.md +0 -58
  14. package/doc/config.md +0 -44
  15. package/doc/draft/chart.md +0 -146
  16. package/doc/draft/data.md +0 -8
  17. package/doc/draft/definition.md +0 -0
  18. package/doc/draft/events.md +0 -0
  19. package/doc/draft/filter.md +0 -0
  20. package/doc/draft/lifecycle.md +0 -89
  21. package/doc/spec.md +0 -89
  22. package/doc/todo.md +0 -27
  23. package/doc/utils/tip.md +0 -84
  24. package/src/chart.ls +0 -320
  25. package/src/chart.styl +0 -6
  26. package/src/data/en-US/category +0 -20
  27. package/src/data/en-US/fruit +0 -39
  28. package/src/data/en-US/movie +0 -125
  29. package/src/data/en-US/name +0 -58
  30. package/src/data/index.ls +0 -34
  31. package/src/data/zh-TW/category +0 -20
  32. package/src/data/zh-TW/fruits +0 -38
  33. package/src/data/zh-TW/movie +0 -125
  34. package/src/data/zh-TW/names +0 -105
  35. package/src/utils/axis.ls +0 -229
  36. package/src/utils/config.ls +0 -11
  37. package/src/utils/data.ls +0 -104
  38. package/src/utils/format.ls +0 -30
  39. package/src/utils/legend.ls +0 -134
  40. package/src/utils/legend.styl +0 -37
  41. package/src/utils/tint.ls +0 -66
  42. package/src/utils/tip.ls +0 -97
  43. package/web/src/pug/base.pug +0 -19
  44. package/web/src/pug/block/axis/0.0.1/index.ls +0 -38
  45. package/web/src/pug/block/axis/0.0.1/index.pug +0 -1
  46. package/web/src/pug/block/axis-bubble/0.0.1/index.ls +0 -141
  47. package/web/src/pug/block/axis-bubble/0.0.1/index.pug +0 -1
  48. package/web/src/pug/block/bar/0.0.1/index.ls +0 -274
  49. package/web/src/pug/block/bar/0.0.1/index.pug +0 -35
  50. package/web/src/pug/block/bar-list/0.0.1/index.ls +0 -85
  51. package/web/src/pug/block/bar-list/0.0.1/index.pug +0 -30
  52. package/web/src/pug/block/bar-race/0.0.1/index.ls +0 -83
  53. package/web/src/pug/block/bar-race/0.0.1/index.pug +0 -21
  54. package/web/src/pug/block/base/0.0.1/index.ls +0 -67
  55. package/web/src/pug/block/base/0.0.1/index.pug +0 -5
  56. package/web/src/pug/block/blank/0.0.1/index.ls +0 -25
  57. package/web/src/pug/block/blank/0.0.1/index.pug +0 -1
  58. package/web/src/pug/block/bubble/0.0.1/index.ls +0 -220
  59. package/web/src/pug/block/bubble/0.0.1/index.pug +0 -28
  60. package/web/src/pug/block/curve-bar/0.0.1/index.ls +0 -89
  61. package/web/src/pug/block/curve-bar/0.0.1/index.pug +0 -16
  62. package/web/src/pug/block/curve-bar/0.0.1/sample.js +0 -338
  63. package/web/src/pug/block/dumbbell/0.0.1/index.ls +0 -90
  64. package/web/src/pug/block/dumbbell/0.0.1/index.pug +0 -1
  65. package/web/src/pug/block/empty/0.0.1/index.ls +0 -27
  66. package/web/src/pug/block/empty/0.0.1/index.pug +0 -2
  67. package/web/src/pug/block/gauge/0.0.1/index.ls +0 -100
  68. package/web/src/pug/block/gauge/0.0.1/index.pug +0 -31
  69. package/web/src/pug/block/gauge/0.0.1/sample.js +0 -338
  70. package/web/src/pug/block/line/0.0.1/index.ls +0 -265
  71. package/web/src/pug/block/line/0.0.1/index.pug +0 -33
  72. package/web/src/pug/block/number/0.0.1/index.ls +0 -69
  73. package/web/src/pug/block/number/0.0.1/index.pug +0 -20
  74. package/web/src/pug/block/percent-list/0.0.1/index.ls +0 -167
  75. package/web/src/pug/block/percent-list/0.0.1/index.pug +0 -34
  76. package/web/src/pug/block/pie/0.0.1/index.ls +0 -125
  77. package/web/src/pug/block/pie/0.0.1/index.pug +0 -19
  78. package/web/src/pug/block/pie/0.0.1/sample.js +0 -338
  79. package/web/src/pug/block/pie-bubble/0.0.1/index.ls +0 -185
  80. package/web/src/pug/block/pie-bubble/0.0.1/index.pug +0 -40
  81. package/web/src/pug/block/radar/0.0.1/index.ls +0 -113
  82. package/web/src/pug/block/radar/0.0.1/index.pug +0 -1
  83. package/web/src/pug/block/radar/0.0.1/xx +0 -285
  84. package/web/src/pug/block/scatter/0.0.1/index.ls +0 -128
  85. package/web/src/pug/block/scatter/0.0.1/index.pug +0 -30
  86. package/web/src/pug/block/sheet/0.0.1/index.ls +0 -38
  87. package/web/src/pug/block/sheet/0.0.1/index.pug +0 -5
  88. package/web/src/pug/block/table/0.0.1/index.ls +0 -40
  89. package/web/src/pug/block/table/0.0.1/index.pug +0 -3
  90. package/web/src/pug/block/taiwantown/0.0.1/index.ls +0 -48
  91. package/web/src/pug/block/taiwantown/0.0.1/index.pug +0 -52
  92. package/web/src/pug/block/taiwanvillage/0.0.1/index.ls +0 -53
  93. package/web/src/pug/block/taiwanvillage/0.0.1/index.pug +0 -52
  94. package/web/src/pug/block/treemap/0.0.1/index.ls +0 -172
  95. package/web/src/pug/block/treemap/0.0.1/index.pug +0 -42
  96. package/web/src/pug/block/voronoi-treemap/0.0.1/index.ls +0 -174
  97. package/web/src/pug/block/voronoi-treemap/0.0.1/index.pug +0 -17
  98. package/web/src/pug/block/voronoi-treemap/0.0.1/sample.js +0 -241
  99. package/web/src/pug/block/wordcloud/0.0.1/index.ls +0 -61
  100. package/web/src/pug/block/wordcloud/0.0.1/index.pug +0 -1
  101. package/web/src/pug/block/worldmap/0.0.1/index.ls +0 -83
  102. package/web/src/pug/block/worldmap/0.0.1/index.pug +0 -12
  103. package/web/src/pug/index.ls +0 -72
  104. package/web/src/pug/index.pug +0 -52
  105. package/web/src/styl/index.styl +0 -0
  106. package/web/static/assets/block/cache.js +0 -4
  107. package/web/static/assets/custom-lib/d3/d3-array.v2.min.js +0 -2
  108. package/web/static/assets/custom-lib/d3/d3-axis.v2.min.js +0 -2
  109. package/web/static/assets/custom-lib/d3/d3-brush.v2.min.js +0 -2
  110. package/web/static/assets/custom-lib/d3/d3-color.v2.min.js +0 -2
  111. package/web/static/assets/custom-lib/d3/d3-dispatch.v2.min.js +0 -2
  112. package/web/static/assets/custom-lib/d3/d3-drag.v2.min.js +0 -2
  113. package/web/static/assets/custom-lib/d3/d3-ease.v2.min.js +0 -2
  114. package/web/static/assets/custom-lib/d3/d3-force-boundary.v0.0.1.min.js +0 -2
  115. package/web/static/assets/custom-lib/d3/d3-force.v2.min.js +0 -2
  116. package/web/static/assets/custom-lib/d3/d3-format.v2.min.js +0 -2
  117. package/web/static/assets/custom-lib/d3/d3-hierarchy.v2.min.js +0 -2
  118. package/web/static/assets/custom-lib/d3/d3-interpolate.v2.min.js +0 -2
  119. package/web/static/assets/custom-lib/d3/d3-path.v2.min.js +0 -2
  120. package/web/static/assets/custom-lib/d3/d3-quadtree.v2.min.js +0 -2
  121. package/web/static/assets/custom-lib/d3/d3-random.v2.min.js +0 -2
  122. package/web/static/assets/custom-lib/d3/d3-scale-chromatic.v1.min.js +0 -2
  123. package/web/static/assets/custom-lib/d3/d3-selection.v2.min.js +0 -2
  124. package/web/static/assets/custom-lib/d3/d3-shape.v2.min.js +0 -2
  125. package/web/static/assets/custom-lib/d3/d3-timer.v2.min.js +0 -2
  126. package/web/static/assets/custom-lib/d3/d3-transition.v2.min.js +0 -2
  127. package/web/static/assets/custom-lib/d3/d3.v4.js +0 -17178
  128. package/web/static/assets/custom-lib/d3/d3.v4.min.js +0 -2
  129. package/web/static/assets/data/countrycode.json +0 -1
  130. package/web/static/assets/data/world-110m.json +0 -1
  131. package/web/static/assets/data/zh-to-alpha2.json +0 -1
  132. package/web/static/assets/img/fluid.svg +0 -16
  133. package/web/static/block/axis/0.0.1/index.html +0 -79
  134. package/web/static/block/axis-bubble/0.0.1/index.html +0 -222
  135. package/web/static/block/bar/0.0.1/index.html +0 -581
  136. package/web/static/block/bar-list/0.0.1/index.html +0 -231
  137. package/web/static/block/bar-race/0.0.1/index.html +0 -184
  138. package/web/static/block/base/0.0.1/index.html +0 -197
  139. package/web/static/block/blank/0.0.1/index.html +0 -42
  140. package/web/static/block/bubble/0.0.1/index.html +0 -402
  141. package/web/static/block/bubble/0.0.1/test.html +0 -0
  142. package/web/static/block/curve-bar/0.0.1/index.html +0 -148
  143. package/web/static/block/dumbbell/0.0.1/index.html +0 -178
  144. package/web/static/block/empty/0.0.1/index.html +0 -76
  145. package/web/static/block/gauge/0.0.1/index.html +0 -150
  146. package/web/static/block/line/0.0.1/index.html +0 -540
  147. package/web/static/block/number/0.0.1/index.html +0 -152
  148. package/web/static/block/percent-list/0.0.1/index.html +0 -316
  149. package/web/static/block/pie/0.0.1/index.html +0 -281
  150. package/web/static/block/pie-bubble/0.0.1/index.html +0 -358
  151. package/web/static/block/radar/0.0.1/index.html +0 -149
  152. package/web/static/block/scatter/0.0.1/index.html +0 -251
  153. package/web/static/block/sheet/0.0.1/index.html +0 -103
  154. package/web/static/block/table/0.0.1/index.html +0 -73
  155. package/web/static/block/taiwantown/0.0.1/index.html +0 -210
  156. package/web/static/block/taiwanvillage/0.0.1/index.html +0 -220
  157. package/web/static/block/treemap/0.0.1/index.html +0 -360
  158. package/web/static/block/voronoi-treemap/0.0.1/index.html +0 -350
  159. package/web/static/block/wordcloud/0.0.1/index.html +0 -92
  160. package/web/static/block/worldmap/0.0.1/index.html +0 -207
  161. package/web/static/css/index.css +0 -0
  162. package/web/static/css/index.min.css +0 -0
  163. package/web/static/favicon.ico +0 -0
  164. package/web/static/index.html +0 -153
package/package.json CHANGED
@@ -3,7 +3,9 @@
3
3
  "name": "@plotdb/chart",
4
4
  "license": "MIT",
5
5
  "description": "plotdb charts",
6
- "version": "0.0.2",
6
+ "main": "dist/index.min.js",
7
+ "files": ["dist/**/*"],
8
+ "version": "1.0.3",
7
9
  "homepage": "https://github.com/plotdb/chart",
8
10
  "repository": {
9
11
  "type": "git",
@@ -14,34 +16,40 @@
14
16
  "npm": ">=6.4.1"
15
17
  },
16
18
  "scripts": {
17
- "start": "npx server -r web -o true",
18
- "postinstall": "npx fedep"
19
+ "start": "npx server -r web -o true"
19
20
  },
20
21
  "devDependencies": {
21
22
  "@loadingio/bootstrap.ext": "^0.0.1",
22
23
  "@loadingio/ldquery": "^2.2.0",
23
24
  "@loadingio/loading.css": "^2.0.1",
24
- "@plotdb/layout": "^0.0.10",
25
+ "@loadingio/vscroll": "^0.0.6",
26
+ "@plotdb/layout": "^0.0.11",
25
27
  "@plotdb/pdmap-world": "^0.0.3",
26
28
  "@plotdb/sheet": "^0.1.7",
27
29
  "@zbryikt/template": "^2.3.22",
28
30
  "bootstrap": "^4.5.2",
31
+ "bootstrap.native": "^3.0.15",
29
32
  "fedep": "^0.0.16",
33
+ "ldiconfont": "^0.1.8",
30
34
  "ldloader": "^2.0.1",
31
35
  "ldview": "^0.2.3",
32
36
  "livescript": "^1.6.0",
37
+ "pdmaptw": "0.0.4",
33
38
  "uglify-js": "^3.2.0",
34
- "uglifycss": "^0.0.29"
39
+ "uglifycss": "^0.0.29",
40
+ "zmgr": "^1.0.0"
35
41
  },
36
42
  "frontendDependencies": {
37
43
  "root": "web/static/assets/lib",
38
44
  "modules": [
39
45
  "bootstrap",
46
+ "bootstrap.native",
40
47
  "@loadingio/bootstrap.ext",
41
48
  "@loadingio/ldquery",
42
49
  "@loadingio/loading.css",
43
50
  "@loadingio/ldcolorpicker",
44
51
  "@loadingio/debounce.js",
52
+ "@loadingio/vscroll",
45
53
  "@plotdb/pdmap-world",
46
54
  "@plotdb/block",
47
55
  "@plotdb/csscope",
@@ -51,33 +59,36 @@
51
59
  "@plotdb/konfig",
52
60
  "@zbryikt/voronoijs",
53
61
  "choosefont.js",
62
+ "pdmaptw",
54
63
  "proxise",
64
+ "ldiconfont",
55
65
  "ldloader",
56
66
  "ldcover",
57
67
  "ldcolor",
58
68
  "ldslider",
59
69
  "wrap-svg-text",
60
70
  "ldpalettepicker",
71
+ "zmgr",
61
72
  "ldview"
62
73
  ]
63
74
  },
64
75
  "dependencies": {
65
76
  "@loadingio/debounce.js": "^0.0.1",
66
77
  "@loadingio/ldcolorpicker": "^2.0.4",
67
- "@plotdb/block": "^2.1.0",
68
- "@plotdb/csscope": "^2.0.0",
69
- "@plotdb/konfig": "^1.2.5",
70
- "@plotdb/rescope": "^3.0.0",
78
+ "@plotdb/block": "^4.0.0",
79
+ "@plotdb/csscope": "^3.0.3",
80
+ "@plotdb/konfig": "^3.0.0",
81
+ "@plotdb/rescope": "^4.0.5",
71
82
  "@zbryikt/voronoijs": "^0.0.1",
72
83
  "choosefont.js": "^0.0.1",
73
84
  "ldcolor": "^0.0.4",
74
85
  "ldcover": "^2.0.0",
75
86
  "ldpalettepicker": "^3.1.3",
76
87
  "ldslider": "^2.0.6",
77
- "proxise": "^0.1.3",
88
+ "proxise": "^0.1.6",
78
89
  "wrap-svg-text": "^0.0.6"
79
90
  },
80
91
  "peerDependencies": {
81
- "proxise": "^0.1.2"
92
+ "proxise": "^0.1.6"
82
93
  }
83
94
  }
package/CHANGELOG.md DELETED
@@ -1,11 +0,0 @@
1
- # Change Logs
2
-
3
- ## v0.0.2
4
-
5
- - use `palette` instead of `pal` in all charts, configurations and utils
6
- - rename `Chart` to `chart`.
7
- - rename `Aniloop` to `aniloop`
8
- - export to `window` only if `module` is not defined.
9
- - add config preset.
10
- - update pie bubble chart
11
- - tweak init and config flow. default config is now available.
package/build DELETED
@@ -1,39 +0,0 @@
1
- #!/usr/bin/env bash
2
-
3
- echo "prepare..."
4
- rm -rf dist/utils
5
- mkdir -p dist/utils
6
-
7
- echo "building livescript files ... "
8
- ./node_modules/.bin/lsc -c --no-header -o dist src
9
-
10
- echo "building stylus files ... "
11
- ./node_modules/.bin/stylus -p src/chart.styl > dist/chart.css
12
- ./node_modules/.bin/stylus -p src/utils/legend.styl > dist/utils/legend.css
13
-
14
- echo "minify chart.js -> chart.min.js ..."
15
- ./node_modules/.bin/uglifyjs dist/chart.js > dist/chart.min.js
16
- echo "minify src/utils/legend.js -> dist/utils/legend.min.js ..."
17
- ./node_modules/.bin/uglifyjs dist/utils/legend.js > dist/utils/legend.min.js
18
- echo "minify src/utils/tint.js -> dist/utils/tint.min.js ..."
19
- ./node_modules/.bin/uglifyjs dist/utils/tint.js > dist/utils/tint.min.js
20
- echo "minify src/utils/data.js -> dist/utils/data.min.js ..."
21
- ./node_modules/.bin/uglifyjs dist/utils/data.js > dist/utils/data.min.js
22
- echo "minify src/utils/axis.js -> dist/utils/axis.min.js ..."
23
- ./node_modules/.bin/uglifyjs dist/utils/axis.js > dist/utils/axis.min.js
24
- echo "minify src/utils/format.js -> dist/utils/format.min.js ..."
25
- ./node_modules/.bin/uglifyjs dist/utils/format.js > dist/utils/format.min.js
26
- echo "minify src/utils/tip.js -> dist/utils/tip.min.js ..."
27
- ./node_modules/.bin/uglifyjs dist/utils/tip.js > dist/utils/tip.min.js
28
- echo "minify src/utils/config.js -> dist/utils/config.min.js ..."
29
- ./node_modules/.bin/uglifyjs dist/utils/config.js > dist/utils/config.min.js
30
-
31
- echo "minifying dist/chart.css ..."
32
- ./node_modules/.bin/uglifycss dist/chart.css > dist/chart.min.css
33
- echo "minifying dist/utils/legend.css ..."
34
- ./node_modules/.bin/uglifycss dist/utils/legend.css > dist/utils/legend.min.css
35
-
36
- echo "copy dist to web ..."
37
- rm -rf "web/static/assets/lib/@plotdb/chart/main/"
38
- mkdir -p "web/static/assets/lib/@plotdb/chart/main/"
39
- cp -R dist/* "web/static/assets/lib/@plotdb/chart/main/"
package/doc/charts.md DELETED
@@ -1,58 +0,0 @@
1
- # Charts to be implemented
2
-
3
- Here we list some charts that we expected to support:
4
-
5
- - bar types
6
- - bar
7
- - stacked bar
8
- - dancing stacked bar
9
- - grouped bar
10
- - 100% stacked bar
11
- - split bar
12
- - column chart variation for all above bars
13
- - line types
14
- - line
15
- - stacked area
16
- - overlapped area
17
- - parallel coordinates
18
- - bump
19
- - map types
20
- - taiwantown ( choropleth )
21
- - taiwanvillage ( choropleth )
22
- - worldmap ( choropleth )
23
- - 3d global ( choropleth )
24
- - event based chart for above charts
25
- - cartogram / dorling cartogram for above charts
26
- - bubble types
27
- - bubble
28
- - axis-bubble
29
- - pie-bubble
30
- - pie types
31
- - pie
32
- - donut
33
- - sunburst
34
- - treemap type
35
- - voronoi-treemap
36
- - treemap
37
- - length type
38
- - dumbbell
39
- - vertical dumbbell
40
- - horizontal dumbbell
41
- - slopegraph
42
- - grouped slopegraph
43
- - sankey type
44
- - sankey chart
45
- - chord chart
46
- - sankey chord
47
- - radial type
48
- - radar chart
49
- - curve bar
50
- - other types
51
- - themeriver
52
- - wordcloud
53
- - violin chart
54
- - combo chart
55
- - scatter type
56
- - scatter chart
57
- - voronoi diagram
58
- - hexagonal bining
package/doc/config.md DELETED
@@ -1,44 +0,0 @@
1
- # configuration
2
-
3
- common configurations for charts.
4
-
5
- ## common / generic ( consider align with common CSS styles? )
6
-
7
- - margin
8
- - font-size
9
- - font-family
10
- - background-color
11
- - color
12
- - palette
13
-
14
-
15
- ## font
16
-
17
- - size
18
- - family
19
-
20
-
21
- ## axis
22
-
23
- - axis-tick
24
- - axis-tick-size-inner
25
- - axis-tick-size-outer
26
- - axis-tick-padding
27
- - axis-tick-count
28
- - axis-tick-format
29
-
30
- ## legend
31
-
32
- - enabled
33
- - selectable
34
-
35
-
36
- ## axis
37
-
38
- - enabled
39
-
40
-
41
- ## tip
42
-
43
- - enabled
44
-
@@ -1,146 +0,0 @@
1
- # Chart Object
2
-
3
- To use a chart definition, construct it with `chart` constructor:
4
-
5
- mychart = new chart({
6
- root: containerElement
7
- mod: myChartDefinition
8
- })
9
-
10
- By above code, `@plotdb/chart` will construct a chart object with mod defined by `myChartDefinition`, and render it in `containerElement`. Further operations and chart controls are all throught the returned `mychart` object.
11
-
12
-
13
- ## Constructor Options
14
-
15
- - `root`: chart container
16
- - `mod`: the chart definition object. see `definition.md` section.
17
- - `config`: config definition in `@plotdb/konfig` spec.
18
- - Config object constructed according this is available as `this.cfg` in chart definition functions.
19
- - `raw`: raw data. optional and can be set later. see `data.md` section.
20
- - `binding`: an object that maps between dimensions of a chart and data. see `data.md` section.
21
- - `hash key`: chart dimension
22
- - `hash val`: mapping data, either a single object or an array of objects which is defined as:
23
- - `key`: field key of data in `raw`
24
- - `name`: field name corresponding to the key. optional
25
- - `unit`: unit of this field. optional
26
- - `dataAccessor(node)`: data accessor function. return `node.data._raw` by default, if omitted.
27
- - `node`: DOM element ( focused, clicked, or any reason when we need the data for certain element )
28
- - should return the raw data object bound to this element, if any, otherwise null.
29
- - used to get data set by chart definition, making it easier to communicate between charts and application.
30
- - see `autoSelect` option for more information.
31
- - `layout`: add a `@plotdb/layout` object if set to true. default true.
32
- - can be either true, false or a layout object.
33
- - false: don't create a layout object automatically.
34
- - true: automatically create a layout object with default options.
35
- - constructued layout looks up `.pdb-layout` under `root` of this chart for the root of layout.
36
- - object: create a `@plotdb/layout` object with this object as custom options
37
- - `prepareSvg`: when true, automatically add an SVG object, if none is available under `root`. default true.
38
- - `delayRender`: set true to prevent chart from rendering until `setRaw` is called. default false
39
- - `useSample`: use sample data if no data provided. default true.
40
- - `autoSelect`: whether to automatically fire `select` / `hover` events. default true.
41
- - when true, it automatically handles select related events with following steps:
42
- - watch hovered / selected events from users' interaction with elements having `data` class.
43
- - when triggered, pass the target node to `dataAccessor` to get bound data.
44
- - pass data through `select` and `hover` events.
45
- - `forceInit`: default false.
46
- - by default, `init` only called after the first `resize` call. set true to force `init` before `resize`.
47
- - sometimes `resize` won't be called until root is visible. `forceInit` can be used to bypass this limitation.
48
-
49
-
50
- Here is a sample chart construction code, with chart definition:
51
-
52
- mychart = new chart({
53
- root: document.body,
54
- data: [{name: "hello"}],
55
- binding: {name: {key: "name"}}
56
- mod: {
57
- render: function() {
58
- this.root.innerText = this.data[0].name;
59
- }
60
- }
61
- });
62
- mychart.render();
63
-
64
-
65
- ## API
66
-
67
- once constructed, the chart object provides following members internally to chart definition:
68
-
69
- - `root`: root element
70
- - `svg`: main svg under root element.
71
- - `box`: {x,y,widht,height} dimension info for `svg` node. update when resize.
72
- - `raw`: raw data from user.
73
- - `binding`: definition of how raw data should be bound to chart.
74
- - `data`: mapped data from `raw` for rendering according to `binding`, with:
75
- - basic format normalization
76
- - additional fields `_idx` and `_raw`:
77
- - `_idx`: order of this item in the list
78
- - `_raw`: original item in raw data
79
- - `seed`: (TBD) a seed for random number generator.
80
-
81
- and following members externally for user:
82
-
83
- - `init()`: init this chart. guaranteed to be executed only once even with multiple calls.
84
- - the overall init process involves following methods and will be taken care by `Chart.init`:
85
- - `init` → `parse` → `bind` → `resize` → `render`
86
- - `destroy()`: destroy this chart.
87
- - `parse()`: parse `raw` into `data`. call `mod.parse` in turn.
88
- - `bind()`: bind data. call `mod.bind` in turn.
89
- - `resize()`: update layout ( if available ), then call `mod.resize` in turn.
90
- - `render()`: render chart by calling `mod.render`.
91
- - `tick()`: called by internal animation loop. call `mod.tick` in turn.
92
- - `start()`: start animation loop.
93
- - `stop()`: stop animation loop.
94
- - `config(opt)`: update config with `opt`. return current configuration if `opt` is omitted.
95
- - `setRaw(raw, binding, reinit)`: set data to `raw`.
96
- - `raw`: data to set.
97
- - `binding`: binding to use. optional.
98
- - `reinit`: default false. true to call `mod.init` again, if already initied.
99
- - `fire(event, payload)`: fire `event` with optional `payload` parameters.
100
- - `on(event, cb)`: handle `event` with `cb` callback.
101
- - `filter(filters, internal)`: filter data based on `filters` config.
102
- - `filters`: object with `key` / `value` pairs for `data field name` / `filter` map.
103
- - `internal`: true if this is called internally.
104
-
105
- Some methods may interact with interfaces from `mod`. For more information, check `lifecycle.md`.
106
-
107
-
108
- ## Chart Definition
109
-
110
- a chart definition is an object with following members:
111
-
112
- - `name`: name of this chart.
113
- - `version`: version of this chart.
114
- - `meta`: additional chart information such as tags, description, author, etc. optional.
115
- - `config`: configuration following `@plotdb/konfig` spec for user interaction and config default values.
116
- - `dimension`: chart dimension definition object.
117
- - `hash key`: dimension name
118
- - `hash val`: object for dimension definition with following members:
119
- - `name`: dimension display name.
120
- - `type`: supported data type, including:
121
- - `N`: Nominal
122
- - `C`: Category
123
- - `O`: Ordinal
124
- - `T`: Ordinal but explicitly declared as time series.
125
- - `R`: Ratio
126
- - `I`: Ratio but explicitly declared as interval type.
127
- - `priority`: number, small is higher. default 100. The priority for binding data automatically.
128
- - `multiple`: true if this dimension support multi-value mapping ( such as y-axis of a line chart )
129
- - `passive`: true if this dimension shouldn't be auto-fitted. default false.
130
- - `i18n`: optional i18n data for translating content.
131
- - chart also provide some common term translation as fallback.
132
- - example:
133
-
134
- { "zh-TW": "some-text": "某些字" }
135
-
136
- - `init()`: called when initialization.
137
- - `destroy()`: called when destroying chart.
138
- - `parse()`: called when data is updated.
139
- - `resize()`: called when container of this chart is resized.
140
- - `bind()`: if parse() is called. this will be called after that. ( TBD )
141
- - `render()`: for rendeing chart.
142
- - `start()`: called when `chart.start` is called.
143
- - `pause()`: called when `chart.pause` is called.
144
- - `tick()`: called periodically if animation loop is started ( by `chart.start` ).
145
- - `mod.tick` should be lightweight as possible. leave heavy work to `render.`
146
- - `render` should be called manually in `tick`, but only if needed.
package/doc/draft/data.md DELETED
@@ -1,8 +0,0 @@
1
-
2
- list of object with keys are field name to corresponding values. For example:
3
- [
4
- {name: "john", score: 85},
5
- {name: "silvia", score: 76},
6
- ...
7
- ]
8
-
File without changes
File without changes
File without changes
@@ -1,89 +0,0 @@
1
- # Chart Life Cycle
2
-
3
- Once created, user should `init` the created chart before using it:
4
-
5
- mychart = new char({ ... });
6
- mychart
7
- .init()
8
- .then( ... );
9
-
10
- And should always `destroy` it when no longer need it:
11
-
12
- mychart.destroy();
13
-
14
-
15
- After initialized usually a chart is also rendered based on the update flow defined by chart definitions. An update flow includes following methods from chart definitions:
16
-
17
- - `init`: initialize object that only have to be initialized one time
18
- - `parse`: parse input raw data on demand.
19
- - `bind`: bind data (TBD)
20
- - `resize`: necessary update for dimensional information changes.
21
- - `render`: render chart.
22
- - `tick`: code run periodically for animation.
23
- - `destroy`: recycle and release resources ( such as timer )
24
-
25
- Above interface methods are expected to be implemented by a chart definition, and there are also counterparts of these methods in `chart` object; these counterparts may do additional works for taking care of the chart lifecycle.
26
-
27
- Different methods may have different update flows. Except `init`, there are some additional functions that may trigger an update flow:
28
-
29
- - `init`
30
- - `setBind`
31
- - `setRaw`
32
- - container / window resized
33
- - layout object re-rendering ( may also be triggered by resizing )
34
-
35
- User should be responsible for lifecycle management for updates from any other types. ( e.g., `config` )
36
-
37
-
38
- ## init
39
-
40
- When calling `init`, it returns a promise which resolves when everything is setup and the chart is rendered. `init` undergoes the following steps:
41
-
42
- - wait for resizeObserver triggers the first resize event, or skip this step if forceInit i true.
43
- - wait until `mod.init` finished. ( if `mod.init` returns a promise )
44
- - wait until `layout.init` finished.
45
- - if `delayRender` is true, wait until `setRaw` is called.
46
- - call `mod.parse`
47
- - call `mod.bind`
48
- - call `mod.resize`
49
- - call `mod.render`
50
-
51
-
52
- ## setRaw
53
-
54
- when `setRaw` is called, data is updated and thus we need a full update:
55
-
56
- - `mod.init`, if `reinit` functional option is true or `delayInit` constructor option is true.
57
- - `mod.parse`
58
- - `mod.bind`
59
- - `mod.resize`
60
- - `mod.render`
61
-
62
- Also resolves the very first `init` function call if `delayInit` is true.
63
-
64
-
65
- ## container resize
66
-
67
- when container resizes, there are only changes in dimension, thus we only need to resize and render:
68
-
69
- - `mod.resize`
70
- - `mod.render`
71
-
72
- ## layout render event
73
- ( TBD why parse and bind )
74
-
75
- when layout `render` event is fired:
76
-
77
- - `mod.parse`
78
- - `mod.bind`
79
- - `mod.resize`
80
- - `mod.render`
81
-
82
- `render` event can be suppressed when calling `layout.update` with additional parameter.
83
-
84
-
85
- ## Additional works in counterpart methods
86
-
87
- - `parse`: inject additional information `_raw` and `_idx` before calling `mod.parse`
88
- - `resize`: update layout ( suppress `render` event ), before calling `mod.resize`
89
-
package/doc/spec.md DELETED
@@ -1,89 +0,0 @@
1
- # Chart Spec.
2
-
3
- PlotDB.js 2.0?
4
-
5
- - consider `plotdb` structure
6
- - abstract certain functionality ( popup? )
7
- - wrapped in `@plotdb/block` for:
8
- - libraries / css isolation so it's possible to run d3v3, v4, v5, v6 at the same time.
9
- - well-defined version / module name
10
- - centralized registry
11
- - `@plotdb/datadom` aware for easily creating webpage with charts.
12
-
13
-
14
- ## Data Object
15
-
16
- Except chart object, we still need additional data for chart to render, including:
17
-
18
- - `raw` - the real data. maybe from database, or from csv, etc.
19
- - `binding` - mapping between data dimension and chart dimension.
20
- - `config` - how chart is rendered.
21
-
22
-
23
- ### Raw
24
-
25
- Raw data. Compiles to array of object ( store in `data` member variable ) according to the given `binding`, with additional fields below in each element:
26
-
27
- - `_idx`: order of this element in `data`.
28
- - `_raw`: raw data corresponding to this object
29
-
30
-
31
-
32
- ### Binding
33
-
34
- binding is an object containing mapping from data fields to map dimensions:
35
-
36
- `dimension-name`: {
37
- key: `field-key`,
38
- name: `field-name`,
39
- description: `field-description`,
40
- filter: <filter-object>
41
- },
42
- `dimension-name`: [
43
- {key: `field-key`}, ...
44
- ]
45
-
46
- detail of the object describing data fields:
47
-
48
- - `key`: unique identifier of the corresponding field. used to look up field values in `raw`.
49
- - `name`: field name. optional. fall back to `key` if not provided.
50
- - `description`: field description. optional.
51
- - `types`: optional. hash of probability for each types. e.g., following types hash suggests a `Category` type:
52
-
53
- {
54
- R: 0.1
55
- O: 0.1
56
- N: 0.3
57
- C: 1.0
58
- }
59
-
60
- - `filter`: filter information about this field. it can be either:
61
- - object with following fields:
62
- - e.g., `{type: "range", value: [1992, 2002]}`
63
- - list of values. e.g., ['Apple', 'Orange']
64
-
65
-
66
- #### Filter
67
-
68
- possible filter format:
69
-
70
- - plain array. indicate chosen values of the specific dimension. e.g., `["Apple", "Orange"]`.
71
- - object in `{type, value}` format, where
72
- - `type`: indicate the type of this filter.
73
- - `value`: value according to the specific type.
74
-
75
-
76
- With following possible types and the meaning of their corresponding value:
77
-
78
- - `index`: an array of position of chosen elements.
79
- - `exclude`: an array of items to be excluded.
80
- - `range`: a 2 elements array indicating the range of chosen values.
81
- - `enum`: an array of chosen elements. identical to the `plain array` format.
82
-
83
-
84
- ## Events
85
-
86
- - `filter`
87
- - `select` / `hover`: fired when some elements with data selected / hovered.A
88
- - n array of `{data, node}` pair should be sent along.
89
-
package/doc/todo.md DELETED
@@ -1,27 +0,0 @@
1
- # todo
2
-
3
- - 如果省略 bind, 則可以直接用 dimension 對應到 data 中的欄位?
4
- - 混合文字的數值也有可能是 type O. 如 104年, 105年, etc
5
- - 在有可能做 unpivot 的情況下, 因為 column 難免要寫上單位(年), 這個問題避不掉, 勢必要處理.
6
- - support zmgr in tip
7
- - performance
8
-
9
-
10
- ## layout
11
-
12
- explicitly define `layout.update`, `layout.render` and consider following scenario:
13
-
14
- chart.resize -> layout.update
15
-
16
- by adding additional action / api such as:
17
-
18
- - before-update
19
- - after-update
20
- - before-render
21
- - after-render
22
-
23
-
24
- ## config
25
-
26
- consider adding additional `config` function for correctly updating config. ( we have `config` now but it's used to set cfg object only. )
27
-