beyond-rails 0.0.219 → 0.0.224

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 996c7b9357d48ee7468378eaf34235b25f2546cb00f28323456638c6d104b038
4
- data.tar.gz: '06392f4a4d63a8f5b643709395ae63b4d4ade3a5ff98e644f5859fdd254d0819'
3
+ metadata.gz: e55ddcbe0f96833cc9e26265b631aceee22acdfc4939e0f6b60e1b4c46498886
4
+ data.tar.gz: cf17d9695a7e2132a571b8caec00640c3082d951bc01893bb5df7948cc359a38
5
5
  SHA512:
6
- metadata.gz: 2e9420822a0c1b1ed7f91505b4b3d14ef63e2330add3114141d34d29ee8592a79e2b2f7225c75e08815169af8c0c918e10488b64ef0b68efc6fbcb2b11b5cd40
7
- data.tar.gz: 1217b6cecb86c65a34b520619f5be9098a4221074d6d367fb4174453518dd8d52e7f5bafa22177da9151e5957a94dcd27a55bee877285c9606fbd26410d6e7e2
6
+ metadata.gz: 2a1b89d81dc3785d4f1cd9c9d2612a8ab144684c1b4904e802394a50be0b5edec0f4087d9998cb466143433a481fb8703a70bfd330f88763e900acc351b0ee9c
7
+ data.tar.gz: 37ccae788cc332c9a25d7dd92f2e6a4ec6dc44ee37d49b160b38abea4a0b10ff3d9bfc2bcb08673fbb0ae60d43560ce45771227e20599a579012c8a239dc5977
@@ -130,6 +130,10 @@ export default class LineChart {
130
130
  return this.xAxisStart + this.contentWidth
131
131
  }
132
132
 
133
+ get xAxisMiddle() {
134
+ return (this.xAxisEnd - this.xAxisStart) / 2
135
+ }
136
+
133
137
  get xRatio() {
134
138
  const lineWidth = this.xAxisEnd - this.xAxisStart
135
139
  const xDelta = this.lastX - this.firstX
@@ -145,6 +149,10 @@ export default class LineChart {
145
149
  return this.yAxisStart - this.contentHeight
146
150
  }
147
151
 
152
+ get yAxisMiddle() {
153
+ return (this.yAxisStart - this.yAxisEnd) / 2
154
+ }
155
+
148
156
  get yRatio() {
149
157
  const lineHeight = this.yAxisStart - this.yAxisEnd
150
158
  const yDelta = Math.abs(this.lastY - this.firstY)
@@ -200,8 +208,17 @@ export default class LineChart {
200
208
  ctx.lineWidth = 2
201
209
 
202
210
  this.pointsArr.forEach((points, i) => {
211
+ const style = lineStyles[i] ? lineStyles[i] : '#000'
212
+
213
+ // only one point in a line
214
+ if (points.length === 1) {
215
+ const pos = pointPosMap.get(points[0])
216
+ this.fillCircle(ctx, pos.x, pos.y, 2, style)
217
+ return
218
+ }
219
+
203
220
  ctx.beginPath()
204
- ctx.strokeStyle = lineStyles[i] ? lineStyles[i] : '#000'
221
+ ctx.strokeStyle = style
205
222
  points.forEach(p => {
206
223
  const pos = pointPosMap.get(p)
207
224
  ctx.lineTo(pos.x, pos.y)
@@ -271,10 +288,13 @@ export default class LineChart {
271
288
 
272
289
  ctx.strokeStyle = '#3c4257'
273
290
 
274
- xLabelRows.forEach((row, i) => {
291
+ let x = this.xAxisMiddle
275
292
 
276
- const x = xAxisStart + ((row.value - firstX) / xRatio)
293
+ xLabelRows.forEach((row, i) => {
277
294
 
295
+ if (xRatio !== 0) {
296
+ x = xAxisStart + ((row.value - firstX) / xRatio)
297
+ }
278
298
  ctx.beginPath()
279
299
  ctx.moveTo(x, scaleStart)
280
300
  ctx.lineTo(x, scaleEnd)
@@ -293,8 +313,12 @@ export default class LineChart {
293
313
  ctx.fillStyle = '#3c4257'
294
314
  ctx.textAlign = 'right'
295
315
 
316
+ let y = this.yAxisMiddle
317
+
296
318
  yLabelRows.forEach(row => {
297
- const y = yAxisStart - ((row.value - firstY) / yRatio)
319
+ if (yRatio !== 0) {
320
+ y = yAxisStart - ((row.value - firstY) / yRatio)
321
+ }
298
322
  ctx.fillText(row.label, x, y - halfYLabelHeight)
299
323
  })
300
324
  }
@@ -505,10 +529,20 @@ export default class LineChart {
505
529
  setPointPos() {
506
530
  const { firstX, firstY, pointPosMap, xAxisStart, xRatio, yAxisStart, yRatio } = this
507
531
 
532
+ // edge case: only one point
533
+ let x = this.xAxisMiddle
534
+ let y = this.yAxisMiddle
535
+
508
536
  this.pointsArr.forEach((points, i) => {
509
537
  points.forEach(point => {
510
- const x = xAxisStart + ((point.x - firstX) / xRatio)
511
- const y = yAxisStart - ((point.y - firstY) / yRatio)
538
+
539
+ if (xRatio !== 0) {
540
+ x = xAxisStart + ((point.x - firstX) / xRatio)
541
+ }
542
+ if (yRatio !== 0) {
543
+ y = yAxisStart - ((point.y - firstY) / yRatio)
544
+ }
545
+
512
546
  const pos = { x, y }
513
547
  pointPosMap.set(point, pos)
514
548
  })
@@ -49,7 +49,19 @@ export default class Modal {
49
49
  this.modal = this.dom
50
50
  }
51
51
 
52
+ triggerShowEventIfNeeded() {
53
+ if (typeof $ === 'function') {
54
+ $(this.dom).trigger('beyond.modal.show')
55
+ }
56
+ }
57
+
52
58
  show(html) {
59
+
60
+ if (this.isVisible && html) {
61
+ this.replace(html)
62
+ return this.triggerShowEventIfNeeded()
63
+ }
64
+
53
65
  if (html) {
54
66
  this.replace(html)
55
67
  }
@@ -57,9 +69,7 @@ export default class Modal {
57
69
  this.modal.style.display = 'block'
58
70
  setTimeout(() => {
59
71
  this.modal.classList.add('js-active')
60
- if (typeof $ === 'function') {
61
- $(this.dom).trigger('beyond.modal.show')
62
- }
72
+ this.triggerShowEventIfNeeded()
63
73
  }, 50)
64
74
  }
65
75
 
@@ -131,6 +131,16 @@ $color-active: #5469d4;
131
131
  text-align: center !important;
132
132
  }
133
133
 
134
+ .float-left {
135
+ float: left !important;
136
+ }
137
+ .float-right {
138
+ float: right !important;
139
+ }
140
+ .float-none {
141
+ float: none !important;
142
+ }
143
+
134
144
  .sr-only {
135
145
  position: absolute;
136
146
  width: 1px;
@@ -90,27 +90,27 @@
90
90
 
91
91
  .#{$classname} {
92
92
  @if $side == '' {
93
- #{$prop}: $space;
93
+ #{$prop}: $space !important;
94
94
  }
95
95
  @else if $side == 't' {
96
- #{$prop}-top: $space;
96
+ #{$prop}-top: $space !important;
97
97
  }
98
98
  @else if $side == 'b' {
99
- #{$prop}-bottom: $space;
99
+ #{$prop}-bottom: $space !important;
100
100
  }
101
101
  @else if $side == 'l' {
102
- #{$prop}-left: $space;
102
+ #{$prop}-left: $space !important;
103
103
  }
104
104
  @else if $side == 'r' {
105
- #{$prop}-right: $space;
105
+ #{$prop}-right: $space !important;
106
106
  }
107
107
  @else if $side == 'x' {
108
- #{$prop}-left: $space;
109
- #{$prop}-right: $space;
108
+ #{$prop}-left: $space !important;
109
+ #{$prop}-right: $space !important;
110
110
  }
111
111
  @else if $side == 'y' {
112
- #{$prop}-top: $space;
113
- #{$prop}-bottom: $space;
112
+ #{$prop}-top: $space !important;
113
+ #{$prop}-bottom: $space !important;
114
114
  }
115
115
  @else {
116
116
  @error "Unknown side #{$side}.";
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: beyond-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.219
4
+ version: 0.0.224
5
5
  platform: ruby
6
6
  authors:
7
7
  - kmsheng
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2020-09-30 00:00:00.000000000 Z
12
+ date: 2020-10-08 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: sassc