@plotdb/chart 0.0.3 → 2.0.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.
Files changed (194) hide show
  1. package/CHANGELOG.md +34 -1
  2. package/README.md +3 -3
  3. package/{dist/data → data}/index.js +0 -0
  4. package/{dist/chart.css → index.css} +0 -0
  5. package/{dist/chart.js → index.js} +3 -1
  6. package/{dist/chart.min.css → index.min.css} +0 -0
  7. package/index.min.js +1 -0
  8. package/package.json +1 -89
  9. package/{dist/utils → utils}/axis.js +6 -0
  10. package/utils/axis.min.js +1 -0
  11. package/{dist/utils → utils}/config.js +0 -0
  12. package/utils/config.min.js +1 -0
  13. package/{dist/utils → utils}/data.js +0 -0
  14. package/utils/data.min.js +1 -0
  15. package/{dist/utils → utils}/format.js +0 -0
  16. package/utils/format.min.js +1 -0
  17. package/{dist/utils → utils}/legend.css +0 -0
  18. package/{dist/utils → utils}/legend.js +0 -0
  19. package/{dist/utils → utils}/legend.min.css +0 -0
  20. package/utils/legend.min.js +1 -0
  21. package/{dist/utils → utils}/tint.js +0 -0
  22. package/utils/tint.min.js +1 -0
  23. package/{dist/utils → utils}/tip.js +0 -0
  24. package/utils/tip.min.js +1 -0
  25. package/build +0 -39
  26. package/dist/chart.min.js +0 -1
  27. package/dist/utils/axis.min.js +0 -1
  28. package/dist/utils/config.min.js +0 -1
  29. package/dist/utils/data.min.js +0 -1
  30. package/dist/utils/format.min.js +0 -1
  31. package/dist/utils/legend.min.js +0 -1
  32. package/dist/utils/tint.min.js +0 -1
  33. package/dist/utils/tip.min.js +0 -1
  34. package/doc/charts.md +0 -58
  35. package/doc/config.md +0 -44
  36. package/doc/draft/chart.md +0 -146
  37. package/doc/draft/data.md +0 -8
  38. package/doc/draft/definition.md +0 -0
  39. package/doc/draft/events.md +0 -0
  40. package/doc/draft/filter.md +0 -0
  41. package/doc/draft/lifecycle.md +0 -89
  42. package/doc/spec.md +0 -89
  43. package/doc/todo.md +0 -27
  44. package/doc/utils/tip.md +0 -84
  45. package/src/chart.ls +0 -323
  46. package/src/chart.styl +0 -6
  47. package/src/data/en-US/category +0 -20
  48. package/src/data/en-US/fruit +0 -39
  49. package/src/data/en-US/movie +0 -125
  50. package/src/data/en-US/name +0 -58
  51. package/src/data/index.ls +0 -34
  52. package/src/data/zh-TW/category +0 -20
  53. package/src/data/zh-TW/fruits +0 -38
  54. package/src/data/zh-TW/movie +0 -125
  55. package/src/data/zh-TW/names +0 -105
  56. package/src/utils/axis.ls +0 -229
  57. package/src/utils/config.ls +0 -11
  58. package/src/utils/data.ls +0 -104
  59. package/src/utils/format.ls +0 -30
  60. package/src/utils/legend.ls +0 -134
  61. package/src/utils/legend.styl +0 -37
  62. package/src/utils/tint.ls +0 -66
  63. package/src/utils/tip.ls +0 -97
  64. package/web/src/pug/base.pug +0 -20
  65. package/web/src/pug/block/axis/0.0.1/index.ls +0 -38
  66. package/web/src/pug/block/axis/0.0.1/index.pug +0 -1
  67. package/web/src/pug/block/axis-bubble/0.0.1/index.ls +0 -141
  68. package/web/src/pug/block/axis-bubble/0.0.1/index.pug +0 -1
  69. package/web/src/pug/block/bar/0.0.1/index.ls +0 -274
  70. package/web/src/pug/block/bar/0.0.1/index.pug +0 -35
  71. package/web/src/pug/block/bar-list/0.0.1/index.ls +0 -85
  72. package/web/src/pug/block/bar-list/0.0.1/index.pug +0 -30
  73. package/web/src/pug/block/bar-race/0.0.1/index.ls +0 -83
  74. package/web/src/pug/block/bar-race/0.0.1/index.pug +0 -21
  75. package/web/src/pug/block/base/0.0.1/index.ls +0 -67
  76. package/web/src/pug/block/base/0.0.1/index.pug +0 -5
  77. package/web/src/pug/block/blank/0.0.1/index.ls +0 -25
  78. package/web/src/pug/block/blank/0.0.1/index.pug +0 -1
  79. package/web/src/pug/block/bubble/0.0.1/index.ls +0 -220
  80. package/web/src/pug/block/bubble/0.0.1/index.pug +0 -28
  81. package/web/src/pug/block/curve-bar/0.0.1/index.ls +0 -89
  82. package/web/src/pug/block/curve-bar/0.0.1/index.pug +0 -16
  83. package/web/src/pug/block/curve-bar/0.0.1/sample.js +0 -338
  84. package/web/src/pug/block/dumbbell/0.0.1/index.ls +0 -90
  85. package/web/src/pug/block/dumbbell/0.0.1/index.pug +0 -1
  86. package/web/src/pug/block/empty/0.0.1/index.ls +0 -27
  87. package/web/src/pug/block/empty/0.0.1/index.pug +0 -2
  88. package/web/src/pug/block/gauge/0.0.1/index.ls +0 -100
  89. package/web/src/pug/block/gauge/0.0.1/index.pug +0 -31
  90. package/web/src/pug/block/gauge/0.0.1/sample.js +0 -338
  91. package/web/src/pug/block/line/0.0.1/index.ls +0 -302
  92. package/web/src/pug/block/line/0.0.1/index.pug +0 -33
  93. package/web/src/pug/block/number/0.0.1/index.ls +0 -69
  94. package/web/src/pug/block/number/0.0.1/index.pug +0 -20
  95. package/web/src/pug/block/percent-list/0.0.1/index.ls +0 -167
  96. package/web/src/pug/block/percent-list/0.0.1/index.pug +0 -34
  97. package/web/src/pug/block/pie/0.0.1/index.ls +0 -125
  98. package/web/src/pug/block/pie/0.0.1/index.pug +0 -19
  99. package/web/src/pug/block/pie/0.0.1/sample.js +0 -338
  100. package/web/src/pug/block/pie-bubble/0.0.1/index.ls +0 -185
  101. package/web/src/pug/block/pie-bubble/0.0.1/index.pug +0 -40
  102. package/web/src/pug/block/radar/0.0.1/index.ls +0 -113
  103. package/web/src/pug/block/radar/0.0.1/index.pug +0 -1
  104. package/web/src/pug/block/radar/0.0.1/xx +0 -285
  105. package/web/src/pug/block/scatter/0.0.1/index.ls +0 -128
  106. package/web/src/pug/block/scatter/0.0.1/index.pug +0 -30
  107. package/web/src/pug/block/sheet/0.0.1/index.ls +0 -38
  108. package/web/src/pug/block/sheet/0.0.1/index.pug +0 -5
  109. package/web/src/pug/block/table/0.0.1/index.ls +0 -40
  110. package/web/src/pug/block/table/0.0.1/index.pug +0 -3
  111. package/web/src/pug/block/taiwancounty/0.0.1/index.ls +0 -74
  112. package/web/src/pug/block/taiwancounty/0.0.1/index.pug +0 -64
  113. package/web/src/pug/block/taiwantown/0.0.1/index.ls +0 -48
  114. package/web/src/pug/block/taiwantown/0.0.1/index.pug +0 -52
  115. package/web/src/pug/block/taiwanvillage/0.0.1/index.ls +0 -53
  116. package/web/src/pug/block/taiwanvillage/0.0.1/index.pug +0 -52
  117. package/web/src/pug/block/treemap/0.0.1/index.ls +0 -172
  118. package/web/src/pug/block/treemap/0.0.1/index.pug +0 -42
  119. package/web/src/pug/block/voronoi-treemap/0.0.1/index.ls +0 -174
  120. package/web/src/pug/block/voronoi-treemap/0.0.1/index.pug +0 -17
  121. package/web/src/pug/block/voronoi-treemap/0.0.1/sample.js +0 -241
  122. package/web/src/pug/block/wordcloud/0.0.1/index.ls +0 -61
  123. package/web/src/pug/block/wordcloud/0.0.1/index.pug +0 -1
  124. package/web/src/pug/block/worldmap/0.0.1/index.ls +0 -81
  125. package/web/src/pug/block/worldmap/0.0.1/index.pug +0 -12
  126. package/web/src/pug/index.ls +0 -72
  127. package/web/src/pug/index.pug +0 -51
  128. package/web/src/styl/index.styl +0 -0
  129. package/web/static/assets/block/cache.js +0 -4
  130. package/web/static/assets/custom-lib/d3/d3-array.v2.js +0 -1182
  131. package/web/static/assets/custom-lib/d3/d3-array.v2.min.js +0 -2
  132. package/web/static/assets/custom-lib/d3/d3-array.v3.js +0 -1273
  133. package/web/static/assets/custom-lib/d3/d3-array.v3.min.js +0 -1273
  134. package/web/static/assets/custom-lib/d3/d3-axis.v2.min.js +0 -2
  135. package/web/static/assets/custom-lib/d3/d3-brush.v2.min.js +0 -2
  136. package/web/static/assets/custom-lib/d3/d3-color.v2.min.js +0 -2
  137. package/web/static/assets/custom-lib/d3/d3-dispatch.v2.min.js +0 -2
  138. package/web/static/assets/custom-lib/d3/d3-drag.v2.min.js +0 -2
  139. package/web/static/assets/custom-lib/d3/d3-ease.v2.min.js +0 -2
  140. package/web/static/assets/custom-lib/d3/d3-force-boundary.v0.0.1.min.js +0 -2
  141. package/web/static/assets/custom-lib/d3/d3-force.v2.min.js +0 -2
  142. package/web/static/assets/custom-lib/d3/d3-format.v2.min.js +0 -2
  143. package/web/static/assets/custom-lib/d3/d3-geo.v2.js +0 -3127
  144. package/web/static/assets/custom-lib/d3/d3-geo.v2.min.js +0 -2
  145. package/web/static/assets/custom-lib/d3/d3-hierarchy.v2.min.js +0 -2
  146. package/web/static/assets/custom-lib/d3/d3-interpolate.v2.min.js +0 -2
  147. package/web/static/assets/custom-lib/d3/d3-path.v2.min.js +0 -2
  148. package/web/static/assets/custom-lib/d3/d3-quadtree.v2.min.js +0 -2
  149. package/web/static/assets/custom-lib/d3/d3-random.v2.min.js +0 -2
  150. package/web/static/assets/custom-lib/d3/d3-scale-chromatic.v1.min.js +0 -2
  151. package/web/static/assets/custom-lib/d3/d3-selection.v2.min.js +0 -2
  152. package/web/static/assets/custom-lib/d3/d3-shape.v2.min.js +0 -2
  153. package/web/static/assets/custom-lib/d3/d3-timer.v2.min.js +0 -2
  154. package/web/static/assets/custom-lib/d3/d3-transition.v2.min.js +0 -2
  155. package/web/static/assets/custom-lib/d3/d3.v4.js +0 -17178
  156. package/web/static/assets/custom-lib/d3/d3.v4.min.js +0 -2
  157. package/web/static/assets/custom-lib/d3/d3.v6.js +0 -19708
  158. package/web/static/assets/data/countrycode.json +0 -1
  159. package/web/static/assets/data/world-110m.json +0 -1
  160. package/web/static/assets/data/zh-to-alpha2.json +0 -1
  161. package/web/static/assets/img/fluid.svg +0 -16
  162. package/web/static/block/axis/0.0.1/index.html +0 -79
  163. package/web/static/block/axis-bubble/0.0.1/index.html +0 -222
  164. package/web/static/block/bar/0.0.1/index.html +0 -581
  165. package/web/static/block/bar-list/0.0.1/index.html +0 -231
  166. package/web/static/block/bar-race/0.0.1/index.html +0 -184
  167. package/web/static/block/base/0.0.1/index.html +0 -197
  168. package/web/static/block/blank/0.0.1/index.html +0 -42
  169. package/web/static/block/bubble/0.0.1/index.html +0 -402
  170. package/web/static/block/bubble/0.0.1/test.html +0 -0
  171. package/web/static/block/curve-bar/0.0.1/index.html +0 -148
  172. package/web/static/block/dumbbell/0.0.1/index.html +0 -178
  173. package/web/static/block/empty/0.0.1/index.html +0 -76
  174. package/web/static/block/gauge/0.0.1/index.html +0 -150
  175. package/web/static/block/line/0.0.1/index.html +0 -571
  176. package/web/static/block/number/0.0.1/index.html +0 -152
  177. package/web/static/block/percent-list/0.0.1/index.html +0 -316
  178. package/web/static/block/pie/0.0.1/index.html +0 -281
  179. package/web/static/block/pie-bubble/0.0.1/index.html +0 -358
  180. package/web/static/block/radar/0.0.1/index.html +0 -149
  181. package/web/static/block/scatter/0.0.1/index.html +0 -251
  182. package/web/static/block/sheet/0.0.1/index.html +0 -103
  183. package/web/static/block/table/0.0.1/index.html +0 -73
  184. package/web/static/block/taiwancounty/0.0.1/index.html +0 -202
  185. package/web/static/block/taiwantown/0.0.1/index.html +0 -210
  186. package/web/static/block/taiwanvillage/0.0.1/index.html +0 -220
  187. package/web/static/block/treemap/0.0.1/index.html +0 -360
  188. package/web/static/block/voronoi-treemap/0.0.1/index.html +0 -350
  189. package/web/static/block/wordcloud/0.0.1/index.html +0 -92
  190. package/web/static/block/worldmap/0.0.1/index.html +0 -207
  191. package/web/static/css/index.css +0 -0
  192. package/web/static/css/index.min.css +0 -0
  193. package/web/static/favicon.ico +0 -0
  194. package/web/static/index.html +0 -153
@@ -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
- });