beyond-rails 0.0.223 → 0.0.224
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/src/js/components/LineChart.js +40 -6
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e55ddcbe0f96833cc9e26265b631aceee22acdfc4939e0f6b60e1b4c46498886
|
4
|
+
data.tar.gz: cf17d9695a7e2132a571b8caec00640c3082d951bc01893bb5df7948cc359a38
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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 =
|
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
|
-
|
291
|
+
let x = this.xAxisMiddle
|
275
292
|
|
276
|
-
|
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
|
-
|
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
|
-
|
511
|
-
|
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
|
})
|
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.
|
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-10-
|
12
|
+
date: 2020-10-08 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: sassc
|