@plotdb/chart 1.0.1 → 1.0.2

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/package.json +3 -1
  2. package/CHANGELOG.md +0 -29
  3. package/build +0 -45
  4. package/doc/charts.md +0 -58
  5. package/doc/config.md +0 -44
  6. package/doc/draft/chart.md +0 -146
  7. package/doc/draft/data.md +0 -8
  8. package/doc/draft/definition.md +0 -0
  9. package/doc/draft/events.md +0 -0
  10. package/doc/draft/filter.md +0 -0
  11. package/doc/draft/lifecycle.md +0 -89
  12. package/doc/spec.md +0 -89
  13. package/doc/todo.md +0 -27
  14. package/doc/utils/tip.md +0 -84
  15. package/src/data/en-US/category +0 -20
  16. package/src/data/en-US/fruit +0 -39
  17. package/src/data/en-US/movie +0 -125
  18. package/src/data/en-US/name +0 -58
  19. package/src/data/index.ls +0 -34
  20. package/src/data/zh-TW/category +0 -20
  21. package/src/data/zh-TW/fruits +0 -38
  22. package/src/data/zh-TW/movie +0 -125
  23. package/src/data/zh-TW/names +0 -105
  24. package/src/index.ls +0 -323
  25. package/src/index.styl +0 -6
  26. package/src/utils/axis.ls +0 -229
  27. package/src/utils/config.ls +0 -11
  28. package/src/utils/data.ls +0 -104
  29. package/src/utils/format.ls +0 -30
  30. package/src/utils/legend.ls +0 -134
  31. package/src/utils/legend.styl +0 -37
  32. package/src/utils/tint.ls +0 -66
  33. package/src/utils/tip.ls +0 -97
  34. package/web/src/pug/base.pug +0 -21
  35. package/web/src/pug/block/axis/0.0.1/index.ls +0 -32
  36. package/web/src/pug/block/axis/0.0.1/index.pug +0 -1
  37. package/web/src/pug/block/axis-bubble/0.0.1/index.ls +0 -137
  38. package/web/src/pug/block/axis-bubble/0.0.1/index.pug +0 -1
  39. package/web/src/pug/block/bar/0.0.1/index.ls +0 -270
  40. package/web/src/pug/block/bar/0.0.1/index.pug +0 -35
  41. package/web/src/pug/block/bar-list/0.0.1/index.ls +0 -81
  42. package/web/src/pug/block/bar-list/0.0.1/index.pug +0 -30
  43. package/web/src/pug/block/bar-race/0.0.1/index.ls +0 -79
  44. package/web/src/pug/block/bar-race/0.0.1/index.pug +0 -21
  45. package/web/src/pug/block/base/0.0.1/index.ls +0 -66
  46. package/web/src/pug/block/base/0.0.1/index.pug +0 -5
  47. package/web/src/pug/block/blank/0.0.1/index.ls +0 -21
  48. package/web/src/pug/block/blank/0.0.1/index.pug +0 -1
  49. package/web/src/pug/block/bubble/0.0.1/index.ls +0 -218
  50. package/web/src/pug/block/bubble/0.0.1/index.pug +0 -42
  51. package/web/src/pug/block/curve-bar/0.0.1/index.ls +0 -85
  52. package/web/src/pug/block/curve-bar/0.0.1/index.pug +0 -16
  53. package/web/src/pug/block/curve-bar/0.0.1/sample.js +0 -338
  54. package/web/src/pug/block/dumbbell/0.0.1/index.ls +0 -86
  55. package/web/src/pug/block/dumbbell/0.0.1/index.pug +0 -1
  56. package/web/src/pug/block/empty/0.0.1/index.ls +0 -28
  57. package/web/src/pug/block/empty/0.0.1/index.pug +0 -2
  58. package/web/src/pug/block/gauge/0.0.1/index.ls +0 -96
  59. package/web/src/pug/block/gauge/0.0.1/index.pug +0 -31
  60. package/web/src/pug/block/gauge/0.0.1/sample.js +0 -338
  61. package/web/src/pug/block/line/0.0.1/index.ls +0 -297
  62. package/web/src/pug/block/line/0.0.1/index.pug +0 -33
  63. package/web/src/pug/block/number/0.0.1/index.ls +0 -65
  64. package/web/src/pug/block/number/0.0.1/index.pug +0 -20
  65. package/web/src/pug/block/percent-list/0.0.1/index.ls +0 -161
  66. package/web/src/pug/block/percent-list/0.0.1/index.pug +0 -34
  67. package/web/src/pug/block/pie/0.0.1/index.ls +0 -121
  68. package/web/src/pug/block/pie/0.0.1/index.pug +0 -19
  69. package/web/src/pug/block/pie/0.0.1/sample.js +0 -338
  70. package/web/src/pug/block/pie-bubble/0.0.1/index.ls +0 -181
  71. package/web/src/pug/block/pie-bubble/0.0.1/index.pug +0 -40
  72. package/web/src/pug/block/radar/0.0.1/index.ls +0 -109
  73. package/web/src/pug/block/radar/0.0.1/index.pug +0 -1
  74. package/web/src/pug/block/radar/0.0.1/xx +0 -285
  75. package/web/src/pug/block/scatter/0.0.1/index.ls +0 -124
  76. package/web/src/pug/block/scatter/0.0.1/index.pug +0 -30
  77. package/web/src/pug/block/sheet/0.0.1/index.ls +0 -34
  78. package/web/src/pug/block/sheet/0.0.1/index.pug +0 -5
  79. package/web/src/pug/block/table/0.0.1/index.ls +0 -36
  80. package/web/src/pug/block/table/0.0.1/index.pug +0 -3
  81. package/web/src/pug/block/taiwancounty/0.0.1/index.ls +0 -70
  82. package/web/src/pug/block/taiwancounty/0.0.1/index.pug +0 -64
  83. package/web/src/pug/block/taiwantown/0.0.1/index.ls +0 -44
  84. package/web/src/pug/block/taiwantown/0.0.1/index.pug +0 -52
  85. package/web/src/pug/block/taiwanvillage/0.0.1/index.ls +0 -49
  86. package/web/src/pug/block/taiwanvillage/0.0.1/index.pug +0 -52
  87. package/web/src/pug/block/treemap/0.0.1/index.ls +0 -168
  88. package/web/src/pug/block/treemap/0.0.1/index.pug +0 -42
  89. package/web/src/pug/block/voronoi-treemap/0.0.1/index.ls +0 -170
  90. package/web/src/pug/block/voronoi-treemap/0.0.1/index.pug +0 -17
  91. package/web/src/pug/block/voronoi-treemap/0.0.1/sample.js +0 -241
  92. package/web/src/pug/block/wordcloud/0.0.1/index.ls +0 -57
  93. package/web/src/pug/block/wordcloud/0.0.1/index.pug +0 -1
  94. package/web/src/pug/block/worldmap/0.0.1/index.ls +0 -77
  95. package/web/src/pug/block/worldmap/0.0.1/index.pug +0 -12
  96. package/web/src/pug/index.ls +0 -72
  97. package/web/src/pug/index.pug +0 -51
  98. package/web/src/styl/index.styl +0 -6
  99. package/web/static/assets/block/cache.js +0 -4
  100. package/web/static/assets/custom-lib/d3/d3-array.v2.js +0 -1182
  101. package/web/static/assets/custom-lib/d3/d3-array.v2.min.js +0 -2
  102. package/web/static/assets/custom-lib/d3/d3-array.v3.js +0 -1273
  103. package/web/static/assets/custom-lib/d3/d3-array.v3.min.js +0 -1273
  104. package/web/static/assets/custom-lib/d3/d3-axis.v2.min.js +0 -2
  105. package/web/static/assets/custom-lib/d3/d3-brush.v2.min.js +0 -2
  106. package/web/static/assets/custom-lib/d3/d3-color.v2.min.js +0 -2
  107. package/web/static/assets/custom-lib/d3/d3-dispatch.v2.min.js +0 -2
  108. package/web/static/assets/custom-lib/d3/d3-drag.v2.min.js +0 -2
  109. package/web/static/assets/custom-lib/d3/d3-ease.v2.min.js +0 -2
  110. package/web/static/assets/custom-lib/d3/d3-force-boundary.v0.0.1.min.js +0 -2
  111. package/web/static/assets/custom-lib/d3/d3-force.v2.min.js +0 -2
  112. package/web/static/assets/custom-lib/d3/d3-format.v2.min.js +0 -2
  113. package/web/static/assets/custom-lib/d3/d3-geo.v2.js +0 -3127
  114. package/web/static/assets/custom-lib/d3/d3-geo.v2.min.js +0 -2
  115. package/web/static/assets/custom-lib/d3/d3-hierarchy.v2.min.js +0 -2
  116. package/web/static/assets/custom-lib/d3/d3-interpolate.v2.min.js +0 -2
  117. package/web/static/assets/custom-lib/d3/d3-path.v2.min.js +0 -2
  118. package/web/static/assets/custom-lib/d3/d3-quadtree.v2.min.js +0 -2
  119. package/web/static/assets/custom-lib/d3/d3-random.v2.min.js +0 -2
  120. package/web/static/assets/custom-lib/d3/d3-scale-chromatic.v1.min.js +0 -2
  121. package/web/static/assets/custom-lib/d3/d3-selection.v2.min.js +0 -2
  122. package/web/static/assets/custom-lib/d3/d3-shape.v2.min.js +0 -2
  123. package/web/static/assets/custom-lib/d3/d3-timer.v2.min.js +0 -2
  124. package/web/static/assets/custom-lib/d3/d3-transition.v2.min.js +0 -2
  125. package/web/static/assets/custom-lib/d3/d3.v4.js +0 -17178
  126. package/web/static/assets/custom-lib/d3/d3.v4.min.js +0 -2
  127. package/web/static/assets/custom-lib/d3/d3.v6.js +0 -19708
  128. package/web/static/assets/data/countrycode.json +0 -1
  129. package/web/static/assets/data/world-110m.json +0 -1
  130. package/web/static/assets/data/zh-to-alpha2.json +0 -1
  131. package/web/static/assets/img/fluid.svg +0 -16
  132. package/web/static/block/axis/0.0.1/index.html +0 -74
  133. package/web/static/block/axis-bubble/0.0.1/index.html +0 -217
  134. package/web/static/block/bar/0.0.1/index.html +0 -576
  135. package/web/static/block/bar-list/0.0.1/index.html +0 -226
  136. package/web/static/block/bar-race/0.0.1/index.html +0 -179
  137. package/web/static/block/base/0.0.1/index.html +0 -197
  138. package/web/static/block/blank/0.0.1/index.html +0 -37
  139. package/web/static/block/bubble/0.0.1/index.html +0 -422
  140. package/web/static/block/bubble/0.0.1/test.html +0 -0
  141. package/web/static/block/curve-bar/0.0.1/index.html +0 -143
  142. package/web/static/block/dumbbell/0.0.1/index.html +0 -173
  143. package/web/static/block/empty/0.0.1/index.html +0 -76
  144. package/web/static/block/gauge/0.0.1/index.html +0 -145
  145. package/web/static/block/line/0.0.1/index.html +0 -566
  146. package/web/static/block/number/0.0.1/index.html +0 -147
  147. package/web/static/block/percent-list/0.0.1/index.html +0 -311
  148. package/web/static/block/pie/0.0.1/index.html +0 -276
  149. package/web/static/block/pie-bubble/0.0.1/index.html +0 -353
  150. package/web/static/block/radar/0.0.1/index.html +0 -144
  151. package/web/static/block/scatter/0.0.1/index.html +0 -246
  152. package/web/static/block/sheet/0.0.1/index.html +0 -98
  153. package/web/static/block/table/0.0.1/index.html +0 -67
  154. package/web/static/block/taiwancounty/0.0.1/index.html +0 -197
  155. package/web/static/block/taiwantown/0.0.1/index.html +0 -205
  156. package/web/static/block/taiwanvillage/0.0.1/index.html +0 -215
  157. package/web/static/block/treemap/0.0.1/index.html +0 -355
  158. package/web/static/block/voronoi-treemap/0.0.1/index.html +0 -345
  159. package/web/static/block/wordcloud/0.0.1/index.html +0 -87
  160. package/web/static/block/worldmap/0.0.1/index.html +0 -202
  161. package/web/static/css/index.css +0 -6
  162. package/web/static/css/index.min.css +0 -1
  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": "1.0.1",
6
+ "main": "dist/index.min.js",
7
+ "files": ["dist/**/*"],
8
+ "version": "1.0.2",
7
9
  "homepage": "https://github.com/plotdb/chart",
8
10
  "repository": {
9
11
  "type": "git",
package/CHANGELOG.md DELETED
@@ -1,29 +0,0 @@
1
- # Change Logs
2
-
3
- ## v1.0.1
4
-
5
- - dont `postinstall npx fedep` since it may lead to installation failure.
6
-
7
-
8
- ## v1.0.0
9
-
10
- - adopt `@plotdb/block` v4 syntax
11
-
12
-
13
- ## v0.0.3
14
-
15
- - upgrade @plotdb/block and related modules. add @loadingio/vscroll
16
- - support Promise-based sample function
17
- - change context of `sample` so we can access `cfg` directly in `sample`
18
- - add taiwancounty chart
19
-
20
-
21
- ## v0.0.2
22
-
23
- - use `palette` instead of `pal` in all charts, configurations and utils
24
- - rename `Chart` to `chart`.
25
- - rename `Aniloop` to `aniloop`
26
- - export to `window` only if `module` is not defined.
27
- - add config preset.
28
- - update pie bubble chart
29
- - tweak init and config flow. default config is now available.
package/build DELETED
@@ -1,45 +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/index.styl > dist/index.css
12
- ./node_modules/.bin/stylus -p src/utils/legend.styl > dist/utils/legend.css
13
-
14
- echo "minify index.js -> index.min.js ..."
15
- ./node_modules/.bin/uglifyjs dist/index.js > dist/index.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/index.css ..."
32
- ./node_modules/.bin/uglifycss dist/index.css > dist/index.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 "legacy chart.css / chart.js ..."
37
- cp dist/index.js dist/chart.js
38
- cp dist/index.min.js dist/chart.min.js
39
- cp dist/index.css dist/chart.css
40
- cp dist/index.min.css dist/chart.min.css
41
-
42
- echo "copy dist to web ..."
43
- rm -rf "web/static/assets/lib/@plotdb/chart/main/"
44
- mkdir -p "web/static/assets/lib/@plotdb/chart/main/"
45
- 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
-
package/doc/utils/tip.md DELETED
@@ -1,84 +0,0 @@
1
- # chart.utils.tip
2
-
3
- tooltip utility. use ldview to render content
4
-
5
- ## usage
6
-
7
- new chart.utils.tip({ ... });
8
-
9
- constructor options:
10
-
11
- - `root`: root node to store tip element.
12
- - one of `relative`, `absolute` or `fixed` position is needed for this element
13
- - `ndoe`: tip node to use. A default one will be created if omitted.
14
- - `margin`: margin between tip and cursor. default 10px if omitted.
15
- - `type`: trigger type of tip. either `over` or `move`. default `move`.
16
- - `accessor`: accessor function for retrieving data from active event.
17
- - default null if omitted.
18
- - if provided, function takes {evt: eventObject} as input, and should return
19
- - null, if no data is bound to this event
20
- - a data object if there is any data bound to this event.
21
- - when provided, `chart.utils.tip` automatically handle mouse events for tip popping.
22
- - `range`: function returning bounding box of tip ( {x,y,width,height} ). optional.
23
- - this box shares the same coordinate origin with `root`'s `getBoundingClientRect`.
24
- - `view`: text handler for ldview. if omitted, handler with following names will be use:
25
- - `name`
26
- - `value`
27
- - `zmgr`: `zmgr` module, use this to get z-index if provided. use `10` instead
28
-
29
-
30
- ## API
31
-
32
- - `render(opt)`: show tip based on the given options:
33
- - `evt`: mouse event. `clientX` and `clientY` members will be used.
34
- - `node`: target node. optional. used to get corresponding bounding box.
35
- - bounding box hints `chart.util.tip` the position a tip should be placed.
36
- - `box`: if `node` is omitted, `render` checks `box` for bounding box information. a box should contains:
37
- - `x` / `y`: left-top coordinate of the box, or centroid of the box if width / height are omitted.
38
- - `width` / `height`: box size, optional.
39
- - `data`: data to be shown. will be set as context to internal ldview object.
40
- - `toggle(v)`: set `v` to true to enable tip, otherwise to disable tip.
41
- - tip is by default enabled after constructed.
42
- - `hide()`: hide tip. this is a debounced function ( with @loadingio/debounce.js ) so you can also `hide().now()`.
43
- - `destroy()`: destroy function, release unused resources.
44
-
45
-
46
- ## Styling
47
-
48
- With d3js, this is the minimal tip construct:
49
-
50
- new chart.utils.tip({
51
- root: myRoot,
52
- accessor: function({evt}) { return (evt.target? d3.select(evt.target).datum() : null); }
53
- });
54
-
55
- To style your own tip, make a tip element first ( with HTML, yet we write this example in Pug for convenience ):
56
-
57
- .my-tip
58
- # ... some fancy design ...
59
- div(ld="name")
60
- div(ld="value")
61
- div(ld="my-custom-field")
62
-
63
- then pass it to tip cosntructor. To support `my-custom-field`, you need to also add `view` option:
64
-
65
- new chart.utils.tip({
66
- node: '.my-tip', ...
67
- view:
68
- name: ({ctx}) -> ctx.name
69
- value: ({ctx}) -> ctx.name
70
- "my-custom-field": ({ctx}) -> some-function(ctx, ctx.some-value);
71
- });
72
-
73
-
74
- ## Custom Behavior
75
-
76
- With `accessor`, `chart.utils.tip` bind action automatically for you. However, you can also decide how tip should interact with your design by calling `render` manually.
77
-
78
- tip = new chart.utils.tip({
79
- /* ... construct without `accessor` option ... */
80
- });
81
- /* only trigger tip when clicking something */
82
- myRoot.addEventListener("click", function(evt) {
83
- tip.render({evt: evt, data: myData});
84
- });
@@ -1,20 +0,0 @@
1
- books
2
- business
3
- education
4
- entertainment
5
- finance
6
- food & drink
7
- games
8
- health & fitness
9
- lifestyle
10
- medical
11
- music
12
- navigation
13
- news
14
- photography
15
- productivity
16
- social network
17
- sports
18
- travel
19
- utilities
20
- weather