@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,40 +0,0 @@
1
- div
2
- div(plug="layout")
3
- .pdl-layout
4
- div(data-type="layout")
5
- .pdl-cell(data-name="view")
6
- .pdl-cell(data-name="legend")
7
- div(data-type="render")
8
- div(data-name="tip") #[div(ld="name")]#[div(ld="value1")]#[div(ld="value2")]
9
- style(type="text/css"): :stylus
10
- /*.pdl-cell { width: 100%; height: 100% }*/
11
- .pdl-layout > div[data-type=layout]
12
- display: grid
13
- grid-template-columns: 1fr fit-content(10em)
14
- & > .pdl-cell[data-name=view]
15
- grid-area: 1 / 1
16
- & > .pdl-cell[data-name=legend]
17
- grid-column: 2
18
- grid-row: 1
19
- padding: 0 .5em 0 .5em
20
-
21
- [data-name=tip]
22
- padding: .4em .5em
23
- background: #13171a
24
- color: #fff
25
- border-radius: 3px
26
- box-shadow: 0 2px 4px rgba(0,0,0,.3)
27
- line-height: 1.2em
28
- font-size: .9em
29
- max-width: 10em
30
- word-break: break-all
31
- [ld=name]
32
- font-size: .85em
33
- [ld=value1], [ld=value2]
34
- font-weight: bold
35
- font-size: 1.1em
36
- line-height: 1.2em
37
-
38
-
39
-
40
- script(type="@plotdb/block"): include:lsc index.ls
@@ -1,113 +0,0 @@
1
- <-(->it!) _
2
-
3
- block-factory =
4
- pkg:
5
- name: 'radar', version: '0.0.1'
6
- extend: {name: "base", version: "0.0.1"}
7
- dependencies: []
8
- init: ({root, context, pubsub}) ->
9
- pubsub.fire \init, mod: mod {context} .then ~> it.0
10
-
11
- mod = ({context}) ->
12
- {d3,forceBoundary,ldColor,repeatString$} = context
13
- sample: ->
14
- raw: [0 to 4].map (idx) ~> {val: [0 to 2].map(->0.5 + 0.5 * Math.random!), cat: idx}
15
- binding:
16
- radius: {key: \val}
17
- order: {key: \cat}
18
- config: {}
19
- dimension:
20
- radius: { type: \R, name: "radius of point on radar line" },
21
- order: { type: \R, name: "order of data point" }
22
- init: ->
23
- svg = d3.select @svg
24
- @gs = gs = {}
25
- gs.all = svg.append \g
26
- @line = d3.line!
27
- .x (d,i) ~> @scale.r(d) * Math.cos(@scale.a(@orders[i]))
28
- .y (d,i) ~> @scale.r(d) * -Math.sin(@scale.a(@orders[i]))
29
- parse: ->
30
- @orders = Array.from(new Set(@data.map(->it.order)))
31
- @parsed = d3.transpose(@data.map(-> it.radius))
32
- @parsed.map (d,i) -> d.idx = i
33
- @names = <[1 2 3]> #@dimension.radius.fieldName || <[1 2 3]>
34
- @radiusRange = d3.extent(@parsed
35
- .map (d) -> d3.extent d
36
- .reduce(((a,b) -> a.concat(b)), [])
37
- )
38
- if @radiusRange.0 == @radiusRange.1 => @radiusRange.1++
39
-
40
- bind: ->
41
- @gs.all.selectAll \path.data .data @parsed
42
- ..exit!
43
- .attr \class, ""
44
- .transition \exit .duration 500
45
- .attr \opacity, 0
46
- .remove!
47
- ..enter!
48
- .append \path
49
- .attr \class, \data
50
- .attr \opacity, 0
51
- @gs.all.selectAll \g.data-group .data @parsed
52
- ..exit!
53
- .attr \class, ""
54
- .transition \exit .duration 500
55
- .attr \opacity, 0
56
- .remove!
57
- ..enter!
58
- .append \g
59
- .attr \class, \data-group
60
- .attr \opacity, 0
61
- @gs.all.selectAll \g.data-group .each (d,i) ->
62
- d3.select @ .selectAll \circle.node .data d
63
- ..exit!
64
- .attr \class, ''
65
- .transition \exit .duration 500
66
- .attr \opacity, 0
67
- .remove!
68
- ..enter!
69
- .append \circle
70
- .attr \class, \node
71
- .attr \opacity, 0
72
- resize: ->
73
- size = (Math.min(@box.width, @box.height) / 2) >? 10
74
- @scale =
75
- r: d3.scaleLinear!domain [0, @radiusRange.1] .range [0, size]
76
- a: d3.scalePoint!domain @orders .range [0, 2 * Math.PI]
77
- c: d3.interpolateTurbo
78
- if @cfg? and @cfg.palette =>
79
- @scale.c = d3.interpolateDiscrete @cfg.palette.colors.map -> ldColor.web(it.value or it)
80
- @aTicks = d3.range(@data.length)
81
- render: ->
82
- {scale, names, line, orders, orders} = @
83
- @gs.all.attr \transform, "translate(#{@box.width/2},#{@box.height/2})"
84
-
85
- @gs.all.selectAll \path.data
86
- .each (d,i) ->
87
- color = scale.c(i / (names.length - 1))
88
- d3.select @
89
- .attr \fill, color
90
- .attr \fill-opacity, 0.2
91
- .attr \stroke, color
92
- .attr \stroke-width, 1
93
- .transition \morph .duration 350
94
- .attr \d, (d,i) -> line(d,i) + "Z"
95
- .transition \opacity .duration 350
96
- .attr \opacity, 1
97
-
98
- @gs.all.selectAll \g.data-group
99
- .each (d,i) ->
100
- color = scale.c(i / (names.length - 1))
101
- d3.select @ .selectAll \circle.node
102
- .attr \fill, \#fff
103
- .attr \stroke, color
104
- .attr \stroke-width, 1
105
- .transition \morph .duration 350
106
- .attr \cx, (d,i) ~> scale.r(d) * Math.cos(scale.a(orders[i]))
107
- .attr \cy, (d,i) ~> scale.r(d) * -Math.sin(scale.a(orders[i]))
108
- .attr \r, 3
109
- .attr \opacity, 1
110
- .transition \opacity .duration 350
111
- .attr \opacity, 1
112
-
113
- return block-factory
@@ -1 +0,0 @@
1
- div: script(type="@plotdb/block"): include:lsc index.ls
@@ -1,285 +0,0 @@
1
- {
2
- sample: function() {
3
- var list = d3.range(9 + Math.round(Math.random() * 3));
4
- var count = d3.range(Math.round(Math.random() * 2) + 2);
5
- return {
6
- order: [{name: "Month", data: list.map(function(d,i) { return plotdb.data.sample.month[i].substring(0,3); })}],
7
- radius: count.map(function(d,i) {
8
- return {
9
- name: "Value " + d,
10
- data: list.map(function(d,i) { return Math.round(Math.random() * 90 + 10); })
11
- };
12
- })
13
- };
14
- },
15
- dimension: {
16
- radius: { type: [plotdb.Number], require: true, multiple: true, desc: "radius of point on radar line" },
17
- order: { type: [plotdb.Order], desc: "order of data point" }
18
- },
19
- config: {
20
- fontFamily: {},
21
- background: {},
22
- textFill: {},
23
- fontSize: {},
24
- margin: {},
25
- padding: {},
26
- palette: {},
27
- strokeWidth: {},
28
- lineSmoothing: {},
29
- legendLabel: {},
30
- legendShow: {},
31
- legendPosition: {},
32
- rAxisShow: {},
33
- rAxisLabel: {},
34
- rAxisTickPadding: {},
35
- rAxisTickCount: {rebindOnChange: true},
36
- aAxisShow: {},
37
- aAxisLabel: {},
38
- aAxisTickPadding: {},
39
- nodeShow: {},
40
- nodeSize: {default: 8},
41
- nodeStrokeWidth: {default: 2},
42
- nodeFill: {default: "#fff"},
43
- gridShow: {},
44
- gridStroke: {},
45
- gridStrokeWidth: {},
46
- gridDashArray: {},
47
- gridBackground: {},
48
- popupShow: {},
49
- unit: {}
50
- },
51
- init: function() {
52
- var that = this;
53
- this.svg = d3.select(this.root).append("svg");
54
- this.allGroup = this.svg.append("g");
55
- this.legendGroup = this.svg.append("g").attr({class: "legend-group"});
56
- this.gridGroup = this.allGroup.append("g").attr({class: "grid-group"});
57
- this.aAxisGroup = this.allGroup.append("g").attr({class: "axis angle"});
58
- this.rAxisGroup = this.allGroup.append("g").attr({class: "axis radius"});
59
- this.popup = plotd3.html.tooltip(this.root).on("mousemove", function(d,i,popup) {
60
- var name = that.names[d3.select(this.parentNode).datum().idx];
61
- var order = that.orders[i];
62
- popup.select(".title").text(name + " @ " + order);
63
- popup.select(".value").text(d + " " + (that.config.unit || ""));
64
- });
65
- this.line = d3.svg.line().tension(0.5)
66
- .x(function(d,i) { return that.rScale(d) * Math.sin( that.aScale(that.orders[i]) ); })
67
- .y(function(d,i) { return that.rScale(d) * -Math.cos( that.aScale(that.orders[i]) ); });
68
- this.overlap = plotd3.rwd.overlap();
69
- },
70
- parse: function() {
71
- plotdb.Order.sort(this.data, "order");
72
- this.orders = d3.map(this.data, function(d,i) { return d.order; }).keys();
73
- this.parsed = d3.transpose(this.data.map(function(it) { return it.radius; }));
74
- this.parsed.map(function(d,i) { d.idx = i; });
75
- this.names = this.dimension.radius.fieldName || ["1","2","3"];
76
- this.radiusRange = d3.extent(this.parsed
77
- .map(function(it) { return d3.extent(it); })
78
- .reduce(function(a,b) { return a.concat(b); }, []));
79
- if(this.radiusRange[0] == this.radiusRange[1]) this.radiusRange[1]++;
80
- },
81
- bind: function() {
82
- var that = this, sel;
83
- sel = this.allGroup.selectAll("path.data").data(this.parsed);
84
- sel.exit().attr("class","").transition("exit").duration(500).attr("opacity",0).remove();
85
- sel.enter().append("path").attr({class: "data", opacity: 0});
86
- sel = this.allGroup.selectAll("g.data-group").data(this.parsed);
87
- sel.exit().attr("class","").transition("exit").duration(500).attr("opacity",0).remove();
88
- sel.enter().append("g").attr({class: "data-group", opacity: 0});
89
- this.allGroup.selectAll("g.data-group").each(function(d,i) {
90
- var sel = d3.select(this).selectAll("circle.node").data(d);
91
- sel.exit().attr("class","").transition("exit").duration(500).attr("opacity",0).remove();
92
- sel = sel.enter().append("circle").attr({class: "node", opacity: 0});
93
- if(that.config.popupShow) that.popup.nodes(sel);
94
- });
95
-
96
- sel = this.gridGroup.selectAll("circle.grid.radius").data(this.rTicks);
97
- sel.exit().attr("class","").transition("exit").duration(500).attr("opacity",0).remove();
98
- sel.enter().append("circle").attr({class: "grid radius",opacity: 0, r: 0}).sort(d3.descending);
99
- this.gridGroup.selectAll("circle.grid.radius").sort(function(a,b) { return b - a;});
100
- sel = this.gridGroup.selectAll("line.grid.angle").data(this.aTicks);
101
- sel.exit().attr("class","").transition("exit").duration(500).attr("opacity",0).remove();
102
- sel.enter().append("line").attr({class: "grid angle",opacity: 0});
103
- sel = this.aAxisGroup.selectAll("g").data(this.aTicks);
104
- sel.exit().attr("class","").transition("exit").duration(500).attr("opacity",0).remove();
105
- sel.enter().append("g").attr({class: "tick"}).each(function(d,i) {
106
- d3.select(this).append("text").attr("opacity", 0);
107
- });
108
- },
109
- resize: function() {
110
- var that = this;
111
- var box = this.root.getBoundingClientRect();
112
- var width = this.width = box.width;
113
- var height = this.height = box.height;
114
- this.svg.attr({
115
- width: width + "px", height: height + "px",
116
- viewBox: [0,0,width,height].join(" "),
117
- preserveAspectRatio: "xMidYMid"
118
- });
119
- this.legendVertical = ( this.config.legendPosition == "left" || this.config.legendPosition == "right" ) ? true : false;
120
- this.line.interpolate(this.config.lineSmoothing);
121
- this.popup.fontSize(this.config.fontSize);
122
- this.cScale = plotdb.Palette.scale.ordinal(this.config.palette);
123
- this.legend = plotd3.rwd.legend()
124
- .scale(this.cScale)
125
- .orient(this.config.legendPosition)
126
- .size(
127
- (this.legendVertical
128
- ? [220,this.height - 2 * this.config.margin]
129
- : [this.width - 2 * this.config.margin, 220]
130
- ))
131
- .label(this.config.legendLabel || " ")
132
- .fontSize(this.config.fontSize);
133
- this.legend.tickValues(this.names);
134
- this.legendGroup.call(this.legend).selectAll(".legend").on("mouseover", function(d,i) {
135
- that.activeGroup = i + 1; that.render();
136
- }).on("mouseout", function(d,i) {
137
- that.activeGroup = null; that.render();
138
- });
139
- this.legendSize = (this.config.legendShow ? this.legend.offset() : [0,0]);
140
- var mh = height - (this.config.legendShow && !this.legendVertical ? this.legendSize[1] + this.config.fontSize : 0);
141
- var mw = width - (this.config.legendShow && this.legendVertical ? this.legendSize[0] + this.config.fontSize : 0);
142
-
143
- this.size = ((mw>mh?mh:mw) - that.config.margin * 2 - that.config.fontSize * 2)/2;
144
- if(this.size <= 10) this.size = 10;
145
- this.rScale = d3.scale.linear()
146
- .domain([0,this.radiusRange[1]])
147
- .range([0,this.size]).nice(5);
148
- this.rTicks = this.rScale.ticks(this.config.rAxisTickCount);
149
- this.rTicks.sort(function(a,b) { return b - a; });
150
- this.niceRRange = this.rScale.domain();
151
- this.rAxis = plotd3.rwd.axis()
152
- .scale(this.rScale)
153
- .orient("radius")
154
- .angle(Math.PI /(this.data.length || 1))
155
- .showGrid(false)
156
- .tickValues(this.rTicks)
157
- .fontSize(this.config.fontSize);
158
- this.rAxisGroup.call(this.rAxis).select(".domain").remove();
159
- this.aScale = d3.scale.ordinal()
160
- .domain(this.orders.concat(""))
161
- .rangePoints([0, 2 * Math.PI]);
162
- this.aTicks = d3.range(this.data.length);
163
- },
164
- render: function() {
165
- var that = this,sel;
166
- if(this.config.fontFamily) d3.select(this.root).style("font-family", this.config.fontFamily);
167
- d3.select(this.root).style("background-color", this.config.background);
168
- this.svg.selectAll("text").attr({
169
- "font-size": that.config.fontSize,
170
- "fill": that.config.textFill
171
- });
172
- this.legendGroup.attr({
173
- transform:
174
- ["translate(",
175
- (this.legendVertical
176
- ? (this.width/2 +
177
- (this.config.legendPosition == "left"
178
- ? -(this.size + this.config.fontSize + this.legendSize[0])
179
- : (this.size + this.config.fontSize)
180
- ))
181
- : (this.width - this.legendSize[0])/2
182
- ),
183
- (!this.legendVertical
184
- ? (this.height/2 +
185
- (this.config.legendPosition == "top"
186
- ? -(this.size + this.config.fontSize + this.legendSize[1])
187
- : (this.size + this.config.fontSize)
188
- ))
189
- : (this.height - this.legendSize[1])/2
190
- ),
191
- ")"].join(" "),
192
- display: (this.config.legendShow ? "block" : "none")
193
- });
194
- this.allGroup.attr({
195
- transform: [
196
- "translate(",
197
- ((this.width + (this.legendVertical ? (this.config.legendPosition == "left" ? 1 : -1) : 0) * (this.config.legendShow
198
- ? this.legendSize[0] + this.config.fontSize
199
- : 0))/2
200
- ), (this.height + (!this.legendVertical ? (this.config.legendPosition == "top" ? 1 : -1) : 0) * (this.config.legendShow
201
- ? this.legendSize[1] + this.config.fontSize : 0))/2,
202
- //(this.height/2),
203
- ")"
204
- ].join(" ")
205
- });
206
- this.gridGroup.attr({
207
- display: (this.config.gridShow ? "block" : "none")
208
- }).selectAll("circle.grid.radius").attr({
209
- cx: 0, cy: 0, fill: this.config.gridBackground, stroke: this.config.gridStroke,
210
- "stroke-width": this.config.gridStrokeWidth, "stroke-dasharray": this.config.gridDashArray
211
- }).transition("morph").duration(500).attr({
212
- r: function(d,i) { return that.rScale(d); },
213
- opacity: 1
214
- });
215
-
216
- this.gridGroup.selectAll("line.grid.angle").attr({
217
- stroke: this.config.gridStroke,
218
- "stroke-width": this.config.gridStrokeWidth,
219
- "stroke-dasharray": this.config.gridDashArray
220
- }).transition("morph").duration(500).attr({
221
- x1: 0, y1: 0,
222
- x2: function(d,i) {
223
- return that.rScale(that.niceRRange[1]) * Math.sin( that.aScale(that.orders[d]) );
224
- },
225
- y2: function(d,i) {
226
- return that.rScale(that.niceRRange[1]) * -Math.cos( that.aScale(that.orders[d]) );
227
- },
228
- opacity: 1
229
- });
230
- this.aAxisGroup.attr({
231
- display: (this.config.aAxisShow ? "block" : "none")
232
- });
233
- this.rAxisGroup.attr({
234
- display: (this.config.rAxisShow ? "block" : "none")
235
- });
236
- this.aAxisGroup.selectAll(".tick text").attr({
237
- "font-size": that.config.fontSize,
238
- "text-anchor": "middle",
239
- dy: "0.38em",
240
- }).text(function(d,i) { return that.orders[i] || i; }).transition("morph").duration(function() {
241
- return d3.select(this).attr("transform") ? 500 : 0;
242
- }).attr({
243
- transform: function(d,i) {
244
- var r = (that.rScale(that.niceRRange[1]) + 1 * that.config.fontSize);
245
- var x = r * Math.sin( that.aScale(that.orders[d]) );
246
- var y = r * -Math.cos( that.aScale(that.orders[d]) );
247
- var a = (360 * i / that.data.length);
248
- return ["translate(", x, y, ") rotate(", a, ")"].join(" ");
249
- },
250
- });
251
- this.aAxisGroup.selectAll("text").transition("opacity").duration(500).attr({ opacity: 1 });
252
- this.allGroup.selectAll("path.data").each(function(d,i) {
253
- var strokeColor = that.cScale(that.names[i]);
254
- var rgb = d3.rgb(strokeColor);
255
- var fillColor = ["rgba(",rgb.r,",",rgb.g,",",rgb.b,",",0.2,")"].join("");
256
- d3.select(this).attr({
257
- fill: fillColor,
258
- stroke: strokeColor,
259
- "stroke-width": that.config.strokeWidth
260
- }).transition("morph").duration(500).attr({
261
- d: function(d,i) { return that.line(d,i) +"Z"; },
262
- });
263
- }).transition("opacity").duration(500).attr({
264
- opacity: function(d,i) { return (!that.activeGroup || that.activeGroup == i+1 ? 1 : 0.1); }
265
- });
266
- this.allGroup.selectAll("g.data-group").each(function(d,i) {
267
- var node = d3.select(this);
268
- var strokeColor = that.cScale(that.names[i]);
269
- var rgb = d3.rgb(strokeColor);
270
- var fillColor = ["rgba(",rgb.r,",",rgb.g,",",rgb.b,",",0.2,")"].join("");
271
- node.selectAll("circle.node").attr({
272
- fill: that.config.nodeFill || "#fff", stroke: strokeColor, "stroke-width": that.config.nodeStrokeWidth,
273
- display: (that.config.nodeShow ? "block" : "none")
274
- }).transition("morph").duration(500).attr({
275
- cx: function(d,i) { return that.rScale(d) * Math.sin( that.aScale(that.orders[i]) ); },
276
- cy: function(d,i) { return that.rScale(d) * -Math.cos( that.aScale(that.orders[i]) ); },
277
- r: that.config.nodeSize/2,
278
- opacity: 1
279
- });
280
- });
281
- this.allGroup.selectAll("g.data-group").transition("opacity").duration(500).attr({
282
- opacity: function(d,i) { return (!that.activeGroup || that.activeGroup == i+1 ? 1 : 0.1); }
283
- });
284
- }
285
- }
@@ -1,128 +0,0 @@
1
- <-(->it!) _
2
-
3
- block-factory =
4
- pkg:
5
- name: 'scatter', version: '0.0.1'
6
- extend: {name: "base", version: "0.0.1"}
7
- dependencies: [
8
- { url: "http://cdn.jsdelivr.net/npm/d3-delaunay@6/dist/d3-delaunay.min.js" }
9
- ]
10
-
11
- init: ({root, context, pubsub}) ->
12
- pubsub.fire \init, mod: mod {context}
13
-
14
- mod = ({context}) ->
15
- {d3,chart} = context
16
- names = [
17
- "The Glenn Miller Story",
18
- "The Fifth Element",
19
- "Forrest Gump",
20
- "Finding Nemo",
21
- "The Fly",
22
- "First Blood",
23
- "You Can't Take It with You",
24
- "Man of the Year",
25
- "From Hell",
26
- "The Easy Rider",
27
- "The English Patient",
28
- "The Extra-Terrestial",
29
- "Edward Scissorhands",
30
- "Empire of the Sun",
31
- "Encounters of the Third Kind",
32
- "Elizabeth: The Golden Age",
33
- ]
34
- sample: ->
35
- raw: [0 to 100].map (val) ~>
36
- ret = x: Math.random!, y: Math.random!, name: names[Math.floor(Math.random! * names.length)]
37
- ret
38
- binding:
39
- x: {key: \x}
40
- y: {key: \y}
41
- name: {key: \name}
42
- config: {}
43
- dimension:
44
- x: {type: \R, name: "x axis"}
45
- y: {type: \R, name: "y axis"}
46
- radius: {type: \R, name: "radius"}
47
- category: {type: \CN, name: "category"}
48
- name: {type: \N, name: "name"}
49
- init: ->
50
- @tint = tint = new chart.utils.tint!
51
- <[view yaxis xaxis]>.map ~> @{}g[it] = d3.select(@layout.get-group(it))
52
- @path = d3.select @svg .append \path
53
-
54
- parse: ->
55
-
56
- resize: ->
57
- [w,h] = [@box.width, @box.height]
58
- @extent =
59
- x: d3.extent @data.map -> it.x
60
- y: d3.extent @data.map -> it.y
61
- box = @layout.get-box \view
62
- @scale =
63
- x: d3.scaleLinear!domain @extent.x .range [0, box.width]
64
- y: d3.scaleLinear!domain @extent.y .range [0, box.height]
65
- @pts = @data.map (d) ~> [@scale.x(d.x), @scale.y(d.y)]
66
- @delaunay = d3.Delaunay.from @pts
67
- @voronoi = @delaunay.voronoi [0, 0, box.width, box.height]
68
- @cells = @pts
69
- .map (point,i) ~>
70
- [x,y] = point
71
- polygon = @voronoi.cellPolygon i
72
- [cx,cy] = centroid = d3.polygonCentroid polygon
73
- area = -d3.polygonArea polygon
74
- angle = (Math.round(Math.atan2(cy - y, cx - x) / Math.PI * 2) + 4) % 4
75
- {point, polygon, centroid, area, angle}
76
-
77
- render: ->
78
- {scale} = @
79
- @g.view.selectAll \circle.data .data @data
80
- ..exit!remove!
81
- ..enter!append \circle .attr \class, \data
82
- .attr \cx, (d,i) -> scale.x d.x
83
- .attr \cy, (d,i) -> scale.y d.y
84
- .attr \r, 3
85
- .attr \fill, \#000
86
- @g.view.selectAll \text .data @data
87
- ..exit!remove!
88
- ..enter!append \text
89
- .text (d,i) -> d.name
90
- .attr \x, (d,i) -> if d.nb => d.nb.x else scale.x(d.x)
91
- .attr \y, (d,i) -> if d.nb => d.nb.y else scale.y(d.y)
92
- .attr \text-anchor, \middle
93
- .attr \dominant-baseline, \middle
94
- @g.view.selectAll \text .data @data
95
- .attr \x, (d,i) -> if d.nb => d.nb.x else scale.x(d.x)
96
- .attr \y, (d,i) -> if d.nb => d.nb.y else scale.y(d.y) - 20
97
- .attr \opacity, (d,i) -> if d.nb => (if d.nb.show => 1 else 0) else 1
98
- @path
99
- .attr \d, @voronoi.render!
100
- .attr \stroke, \#000
101
- .attr \transform, @g.view.node!getAttribute(\transform)
102
- tick: ->
103
- scale = @scale
104
- @g.view.selectAll \text .each (d,i) -> d.box = @getBoundingClientRect!
105
- rbox = @layout.get-box \view
106
- for i from 0 til @data.length =>
107
- d = @data[i].box
108
- if !@data[i].nb => @data[i].nb = x: scale.x(@data[i].x), y: scale.y(@data[i].y) - 20
109
- @data[i].nb <<< width: d.width, height: d.height, show: true
110
- for r from 20 til 200 by 20
111
- for i from 0 til @data.length =>
112
- for j from 0 til i =>
113
- [a,b] = [@data[i].nb, @data[j].nb]
114
- if ((a.x >= b.x and a.x <= b.x + b.width) or (a.x + a.width >= b.x and a.x + a.width <= b.x + b.width)) and
115
- ((a.y >= b.y and a.y <= b.y + b.height) or (a.y + a.height >= b.y and a.y + a.height <= b.y + b.height)) =>
116
- d = Math.random! * Math.PI * 2
117
- data = @data[i]
118
- data.nb <<< {x: scale.x(data.x) + (Math.cos(d) * r), y: scale.y(data.y) + (Math.sin(d) * r)}
119
- for i from 0 til @data.length =>
120
- for j from 0 til i =>
121
- [a,b] = [@data[i].nb, @data[j].nb]
122
- if ((a.x >= b.x and a.x <= b.x + b.width) or (a.x + a.width >= b.x and a.x + a.width <= b.x + b.width)) and
123
- ((a.y >= b.y and a.y <= b.y + b.height) or (a.y + a.height >= b.y and a.y + a.height <= b.y + b.height)) =>
124
- @data[i].nb.show = false
125
-
126
- @render!
127
-
128
- return block-factory
@@ -1,30 +0,0 @@
1
- div
2
- div(plug="layout")
3
- .pdl-layout
4
- div(data-type="layout")
5
- .pdl-cell(data-name="axis-left")
6
- .pdl-cell(data-name="view")
7
- .pdl-cell
8
- .pdl-cell(data-name="axis-bottom")
9
- .pdl-cell(data-name="legend")
10
- div(data-type="render")
11
- style(type="text/css"): :stylus
12
- .pdl-layout > div[data-type=layout]
13
- display: grid
14
- grid-template-columns: 2em 1fr
15
- grid-template-rows: 1fr 1em 3em
16
- padding: 20px 20px 0 20px
17
- .pdl-cell[data-name=legend]
18
- grid-column: 1 / span 2
19
- grid-row: 3
20
- /*
21
- .pdl-layout > div[data-type=layout]
22
- display: grid
23
- grid-template-columns: 2em 1fr 5em
24
- grid-template-rows: 1fr 1em
25
- padding: 20px 20px 0 20px
26
- .pdl-cell[data-name=legend]
27
- grid-column: 3
28
- grid-row: 1 / span 2
29
- */
30
- script(type="@plotdb/block"): include:lsc index.ls
@@ -1,38 +0,0 @@
1
- <-(->it!) _
2
-
3
- block-factory =
4
- pkg:
5
- name: 'bar', version: '0.0.1'
6
- extend: {name: "base", version: "0.0.1"}
7
- dependencies: [
8
- {url: "/assets/lib/@plotdb/sheet/main/index.min.js"}
9
- {url: "/assets/lib/@plotdb/sheet/main/index.min.css"}
10
- ]
11
- init: ({root, context, t, pubsub}) ->
12
- pubsub.fire \init, mod: mod({context, t}), prepareSvg: false, layout: false
13
-
14
- mod = ({context, t}) ->
15
- {chart,sheet} = context
16
- sample: ->
17
- raw: [0 to 20].map (val) ~> Object.fromEntries([1 to 5].map -> ["col#it", (Math.random! * 100).toFixed(2)])
18
- binding: column: [1 to 5].map -> {key: "col#it"}
19
- config: {}
20
- dimension: column: {type: \NCOR, multiple: true, name: \column}
21
- init: ->
22
- @sheet = new sheet do
23
- root: @root.querySelector('[plug=layout]')
24
- frozen: {row: 1}
25
- editing: false
26
- idx: row: true, col: true
27
- @data = [@binding.column.map(->it.name or it.key)] ++ @raw.map (r) ~> @binding.column.map (c) -> r[c.key]
28
- @sheet.data @data
29
-
30
- filter: (filters, internal = false) ->
31
- parse: ->
32
- head = @binding.column.map -> it.name or it.key
33
- @parsed = [head] ++ (@data.map -> it.column)
34
- @sheet.data @parsed
35
- resize: ->
36
- render: ->
37
-
38
- return block-factory
@@ -1,5 +0,0 @@
1
- div
2
- div(plug="layout")
3
- style(type="text/css"): :stylus
4
-
5
- script(type="@plotdb/block"): include:lsc index.ls
@@ -1,40 +0,0 @@
1
- <-(->it!) _
2
-
3
- block-factory =
4
- pkg:
5
- name: 'table', version: '0.0.1'
6
- extend: {name: "empty", version: "0.0.1"}
7
- dependencies: [
8
- {url: "/assets/lib/gridjs/main/gridjs.production.min.js"}
9
- {url: "/assets/lib/gridjs/main/theme/mermaid.min.css"}
10
- ]
11
- init: ({root, context, pubsub}) ->
12
- {gridjs} = context
13
- pubsub.fire \init, {
14
- layout: false
15
- prepare-svg: false
16
- mod: {
17
- init: ->
18
- @grid = grid = new gridjs.Grid do
19
- columns: [' ',' ',' ',' ',' '],
20
- height: "#{@root.getBoundingClientRect!height}px"
21
- fixedHeader: true,
22
- sort: true
23
- search: false
24
- resizable: true
25
- data: [] ++ [0 to 10].map -> []
26
- grid.render @root
27
- parse: ->
28
- head = [k for k of (@raw.0 or {})]
29
- head.length
30
- raw = @raw
31
- console.log raw
32
- return
33
- @grid.updateConfig {
34
- columns: raw.0
35
- data: raw.slice(1) ++ [0 to (20 - raw.length) >? 0 ].map(->[])
36
- } .forceRender!
37
- }
38
- }
39
-
40
- return block-factory