@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
@@ -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,124 +0,0 @@
1
- module.exports =
2
- pkg:
3
- name: 'scatter', version: '0.0.1'
4
- extend: {name: "base", version: "0.0.1"}
5
- dependencies: [
6
- { url: "http://cdn.jsdelivr.net/npm/d3-delaunay@6/dist/d3-delaunay.min.js" }
7
- ]
8
-
9
- init: ({root, context, pubsub}) ->
10
- pubsub.fire \init, mod: mod {context}
11
-
12
- mod = ({context}) ->
13
- {d3,chart} = context
14
- names = [
15
- "The Glenn Miller Story",
16
- "The Fifth Element",
17
- "Forrest Gump",
18
- "Finding Nemo",
19
- "The Fly",
20
- "First Blood",
21
- "You Can't Take It with You",
22
- "Man of the Year",
23
- "From Hell",
24
- "The Easy Rider",
25
- "The English Patient",
26
- "The Extra-Terrestial",
27
- "Edward Scissorhands",
28
- "Empire of the Sun",
29
- "Encounters of the Third Kind",
30
- "Elizabeth: The Golden Age",
31
- ]
32
- sample: ->
33
- raw: [0 to 100].map (val) ~>
34
- ret = x: Math.random!, y: Math.random!, name: names[Math.floor(Math.random! * names.length)]
35
- ret
36
- binding:
37
- x: {key: \x}
38
- y: {key: \y}
39
- name: {key: \name}
40
- config: {}
41
- dimension:
42
- x: {type: \R, name: "x axis"}
43
- y: {type: \R, name: "y axis"}
44
- radius: {type: \R, name: "radius"}
45
- category: {type: \CN, name: "category"}
46
- name: {type: \N, name: "name"}
47
- init: ->
48
- @tint = tint = new chart.utils.tint!
49
- <[view yaxis xaxis]>.map ~> @{}g[it] = d3.select(@layout.get-group(it))
50
- @path = d3.select @svg .append \path
51
-
52
- parse: ->
53
-
54
- resize: ->
55
- [w,h] = [@box.width, @box.height]
56
- @extent =
57
- x: d3.extent @data.map -> it.x
58
- y: d3.extent @data.map -> it.y
59
- box = @layout.get-box \view
60
- @scale =
61
- x: d3.scaleLinear!domain @extent.x .range [0, box.width]
62
- y: d3.scaleLinear!domain @extent.y .range [0, box.height]
63
- @pts = @data.map (d) ~> [@scale.x(d.x), @scale.y(d.y)]
64
- @delaunay = d3.Delaunay.from @pts
65
- @voronoi = @delaunay.voronoi [0, 0, box.width, box.height]
66
- @cells = @pts
67
- .map (point,i) ~>
68
- [x,y] = point
69
- polygon = @voronoi.cellPolygon i
70
- [cx,cy] = centroid = d3.polygonCentroid polygon
71
- area = -d3.polygonArea polygon
72
- angle = (Math.round(Math.atan2(cy - y, cx - x) / Math.PI * 2) + 4) % 4
73
- {point, polygon, centroid, area, angle}
74
-
75
- render: ->
76
- {scale} = @
77
- @g.view.selectAll \circle.data .data @data
78
- ..exit!remove!
79
- ..enter!append \circle .attr \class, \data
80
- .attr \cx, (d,i) -> scale.x d.x
81
- .attr \cy, (d,i) -> scale.y d.y
82
- .attr \r, 3
83
- .attr \fill, \#000
84
- @g.view.selectAll \text .data @data
85
- ..exit!remove!
86
- ..enter!append \text
87
- .text (d,i) -> d.name
88
- .attr \x, (d,i) -> if d.nb => d.nb.x else scale.x(d.x)
89
- .attr \y, (d,i) -> if d.nb => d.nb.y else scale.y(d.y)
90
- .attr \text-anchor, \middle
91
- .attr \dominant-baseline, \middle
92
- @g.view.selectAll \text .data @data
93
- .attr \x, (d,i) -> if d.nb => d.nb.x else scale.x(d.x)
94
- .attr \y, (d,i) -> if d.nb => d.nb.y else scale.y(d.y) - 20
95
- .attr \opacity, (d,i) -> if d.nb => (if d.nb.show => 1 else 0) else 1
96
- @path
97
- .attr \d, @voronoi.render!
98
- .attr \stroke, \#000
99
- .attr \transform, @g.view.node!getAttribute(\transform)
100
- tick: ->
101
- scale = @scale
102
- @g.view.selectAll \text .each (d,i) -> d.box = @getBoundingClientRect!
103
- rbox = @layout.get-box \view
104
- for i from 0 til @data.length =>
105
- d = @data[i].box
106
- if !@data[i].nb => @data[i].nb = x: scale.x(@data[i].x), y: scale.y(@data[i].y) - 20
107
- @data[i].nb <<< width: d.width, height: d.height, show: true
108
- for r from 20 til 200 by 20
109
- for i from 0 til @data.length =>
110
- for j from 0 til i =>
111
- [a,b] = [@data[i].nb, @data[j].nb]
112
- 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
113
- ((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)) =>
114
- d = Math.random! * Math.PI * 2
115
- data = @data[i]
116
- data.nb <<< {x: scale.x(data.x) + (Math.cos(d) * r), y: scale.y(data.y) + (Math.sin(d) * r)}
117
- for i from 0 til @data.length =>
118
- for j from 0 til i =>
119
- [a,b] = [@data[i].nb, @data[j].nb]
120
- 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
121
- ((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)) =>
122
- @data[i].nb.show = false
123
-
124
- @render!
@@ -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,34 +0,0 @@
1
- module.exports =
2
- pkg:
3
- name: 'bar', version: '0.0.1'
4
- extend: {name: "base", version: "0.0.1"}
5
- dependencies: [
6
- {url: "/assets/lib/@plotdb/sheet/main/index.min.js"}
7
- {url: "/assets/lib/@plotdb/sheet/main/index.min.css"}
8
- ]
9
- init: ({root, context, t, pubsub}) ->
10
- pubsub.fire \init, mod: mod({context, t}), prepareSvg: false, layout: false
11
-
12
- mod = ({context, t}) ->
13
- {chart,sheet} = context
14
- sample: ->
15
- raw: [0 to 20].map (val) ~> Object.fromEntries([1 to 5].map -> ["col#it", (Math.random! * 100).toFixed(2)])
16
- binding: column: [1 to 5].map -> {key: "col#it"}
17
- config: {}
18
- dimension: column: {type: \NCOR, multiple: true, name: \column}
19
- init: ->
20
- @sheet = new sheet do
21
- root: @root.querySelector('[plug=layout]')
22
- frozen: {row: 1}
23
- editing: false
24
- idx: row: true, col: true
25
- @data = [@binding.column.map(->it.name or it.key)] ++ @raw.map (r) ~> @binding.column.map (c) -> r[c.key]
26
- @sheet.data @data
27
-
28
- filter: (filters, internal = false) ->
29
- parse: ->
30
- head = @binding.column.map -> it.name or it.key
31
- @parsed = [head] ++ (@data.map -> it.column)
32
- @sheet.data @parsed
33
- resize: ->
34
- render: ->
@@ -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,36 +0,0 @@
1
- module.exports =
2
- pkg:
3
- name: 'table', version: '0.0.1'
4
- extend: {name: "empty", version: "0.0.1"}
5
- dependencies: [
6
- {url: "/assets/lib/gridjs/main/gridjs.production.min.js"}
7
- {url: "/assets/lib/gridjs/main/theme/mermaid.min.css"}
8
- ]
9
- init: ({root, context, pubsub}) ->
10
- {gridjs} = context
11
- pubsub.fire \init, {
12
- layout: false
13
- prepare-svg: false
14
- mod: {
15
- init: ->
16
- @grid = grid = new gridjs.Grid do
17
- columns: [' ',' ',' ',' ',' '],
18
- height: "#{@root.getBoundingClientRect!height}px"
19
- fixedHeader: true,
20
- sort: true
21
- search: false
22
- resizable: true
23
- data: [] ++ [0 to 10].map -> []
24
- grid.render @root
25
- parse: ->
26
- head = [k for k of (@raw.0 or {})]
27
- head.length
28
- raw = @raw
29
- console.log raw
30
- return
31
- @grid.updateConfig {
32
- columns: raw.0
33
- data: raw.slice(1) ++ [0 to (20 - raw.length) >? 0 ].map(->[])
34
- } .forceRender!
35
- }
36
- }
@@ -1,3 +0,0 @@
1
- div(style="height:100%")
2
- plug(name="layout")
3
- script(type="@plotdb/block"): include:lsc index.ls
@@ -1,70 +0,0 @@
1
- module.exports =
2
- pkg:
3
- name: 'taiwancounty', version: '0.0.1'
4
- extend: {name: "base", version: "0.0.1"}
5
- dependencies: [
6
- {url: "https://d3js.org/topojson.v2.min.js", async: false}
7
- {url: "https://d3js.org/d3-geo.v2.min.js", async: false}
8
- {name: "pdmaptw", version: "local", path: "index.min.js", async: false}
9
- {name: "pdmaptw", version: "local", path: "county.map.js"}
10
- ]
11
- init: ({root, context, pubsub}) ->
12
- pubsub.fire \init, mod: mod {context} .then ~> it.0
13
-
14
- mod = ({context}) ->
15
- {chart, d3, ldcolor, pdmaptw, topojson} = context
16
- sample: ->
17
- pdmaptw.get('county').then ({meta, topo}) ->
18
- raw: meta.name.map -> {val: Math.random!, name: pdmaptw.normalize it}
19
- binding: color: {key: \val}, name: {key: \name}
20
- config:
21
- palette: type: \palette
22
- dimension:
23
- name: {type: \N, name: "國家"}
24
- color: {type: \R, name: "顏色"}
25
- init: ->
26
- @g = @layout.get-group \view
27
- @obj = new pdmaptw {root: @g, type: \county}
28
- @scale = scale = {color: d3.interpolateTurbo}
29
- @legend = new chart.utils.legend do
30
- root: @root
31
- name: \legend
32
- layout: @layout
33
- shape: (d) -> d3.select(@).attr \fill, scale.color d.key
34
- @tip = new chart.utils.tip {
35
- root: @root,
36
- accessor: ({evt}) ~>
37
- if !(evt.target and data = d3.select(evt.target).datum!) => return null
38
- return {name: data.data.name, value: data.data.color}
39
- range: ~> return @layout.get-node \view .getBoundingClientRect!
40
- }
41
- @obj.init!then ~> @obj.fit {node: @g, box: @layout.get-node(\view).getBoundingClientRect!}
42
-
43
- parse: ->
44
- @extent = c: [undefined, undefined]
45
- d3.select @svg .selectAll \path .each (d,i) ~>
46
- d.data = @data.filter(-> it.name == d.properties.name).0 or {}
47
- if !(@extent.c.0?) or d.data.color < @extent.c.0 => @extent.c.0 = d.data.color
48
- if !(@extent.c.1?) or d.data.color > @extent.c.1 => @extent.c.1 = d.data.color
49
-
50
- resize: ->
51
- @tip.toggle(if @cfg.{}tip.enabled? => @cfg.tip.enabled else true)
52
- @obj.fit @layout.get-box \view
53
- pal = if @cfg.palette => @cfg.palette.colors else <[#f00 #999 #00f]>
54
- len = pal.length
55
- @ticks = d3.quantize((~> (1 - it) * (@extent.c.1 - @extent.c.0) + @extent.c.0), len).map ~>
56
- {key: it, text: d3.format(@cfg.legend-format or '.2f')(it) + (if @binding.color.unit => that else '')}
57
- @ticks.sort (a,b) -> a.key - b.key
58
- if @cfg.palette =>
59
- @scale.color = d3.scaleLinear!
60
- .domain @ticks.map(-> it.key)
61
- .range pal.map -> ldcolor.web(it.value or it)
62
- @legend.data @ticks
63
- @obj.fit {node: @g, box: @layout.get-box(\view)}
64
-
65
- render: ->
66
- d3.select @svg .selectAll \path
67
- .transition!duration 350
68
- .attr \fill, (d,i) ~> @scale.color d.data.color
69
- .attr \fill-opacity, (d,i) ~> if @cfg.dim-empty => (if d.data.color? => 1 else 0.2) else 1
70
- @legend.render!
@@ -1,64 +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") 123
7
- div(data-type="render")
8
- style(type="text/css"): :stylus
9
- .pdl-layout > div[data-type=layout]
10
- display: grid
11
- grid-template-columns: 1fr fit-content(5em)
12
- script(type="@plotdb/block"): include:lsc index.ls
13
-
14
-
15
- //-div: script(type="@plotdb/block"): :lsc
16
- {
17
- pkg:
18
- name: 'taiwantown', version: '0.0.1'
19
- dependencies: [
20
- {url: "https://d3js.org/d3.v4.js", async: false}
21
- "https://d3js.org/d3-format.v2.min.js"
22
- "https://d3js.org/d3-array.v2.min.js"
23
- "https://d3js.org/topojson.v2.min.js"
24
- {url: "https://d3js.org/d3-color.v1.min.js", async: false}
25
- {url: "https://d3js.org/d3-interpolate.v1.min.js", async: false}
26
- {url: "https://d3js.org/d3-scale-chromatic.v1.min.js", async: false}
27
- "/js/map.list.js"
28
- "https://cdn.jsdelivr.net/npm/pdmaptw@0.0.2/dist/pdmaptw.min.js"
29
- ]
30
- init: ({root, context}) ->
31
- counties = context.counties.map (d,i) -> {val: Math.random!, county: d}
32
- towns = context.towns.map (d,i) -> {val: Math.random!, town: d}
33
- c = new chart do
34
- root: root
35
- raw: towns
36
- mod: @mod({context})
37
- binding: do
38
- color: {name: \val}
39
- name: {name: \town}
40
- c.init!then -> c.render!
41
- @c = c
42
-
43
- interface: -> @c
44
-
45
- mod: ({context}) ->
46
- return do
47
- init: ->
48
- @obj = context.pdmaptw.create do
49
- root: @svg
50
- type: \town
51
- baseurl: 'https://cdn.jsdelivr.net/npm/pdmaptw@0.0.2/dist'
52
- @obj.init!then ~> @obj.fit!
53
- parse: ->
54
- d3.select @svg .selectAll \path .each (d,i) ~>
55
- d.data = @data.filter(-> it.name == d.properties.name).0 or {}
56
- resize: -> #@obj.fit!
57
- render: ->
58
- @color = d3.interpolateTurbo
59
- if config.pal => @color = d3.interpolateDiscrete config.pal
60
- d3.select @svg .selectAll \path
61
- .transition!duration 350
62
- .attr \fill, (d,i) ~> @color d.data.color
63
-
64
- }