juijs-chart
Advanced tools
Comparing version 2.6.0 to 2.6.1
@@ -18,3 +18,3 @@ import jui from '../src/main.js' | ||
x : { | ||
domain : [ "1 year ago", "1 month ago", "Yesterday", "Today" ], | ||
domain : [ "1 year ago", "1 month ago" ], | ||
line : true | ||
@@ -37,3 +37,3 @@ }, | ||
error : [ 0 ], | ||
errorText : "Stopped", | ||
errorText : "Server Down", | ||
unit : 10 | ||
@@ -62,3 +62,6 @@ }], | ||
}, | ||
interval : 100 | ||
interval : 100, | ||
style : { | ||
} | ||
}); | ||
@@ -71,4 +74,2 @@ | ||
{ normal : 10, warning : 8, fatal : 5 }, | ||
{ normal : 6, warning : 4, fatal : 10 }, | ||
{ normal : 5, warning : 5, fatal : 7 } | ||
]); | ||
@@ -79,6 +80,4 @@ } else { | ||
{ normal : 10, warning : 8, fatal : 5 }, | ||
{ normal : 6, warning : 4, fatal : 10 }, | ||
{ normal : 5, warning : 5, fatal : 7 } | ||
]); | ||
} | ||
}); |
{ | ||
"name": "juijs-chart", | ||
"version": "2.6.0", | ||
"version": "2.6.1", | ||
"sideEffects": false, | ||
@@ -5,0 +5,0 @@ "description": "SVG-based JUI chart that can be used in the browser and Node.js. Support many types of charts. (Dashboard, Map, Topology, Full 3D)", |
@@ -56,2 +56,13 @@ import jui from '../../main.js'; | ||
this.isErrorColumn = function(i) { | ||
const error = this.brush.error; | ||
if ((_.typeCheck("array", error) && !error.includes(i)) || | ||
(_.typeCheck("integer", error) && error !== i) || error === null) { | ||
return false; | ||
} | ||
return true; | ||
} | ||
this.drawBefore = function() { | ||
@@ -65,3 +76,2 @@ zeroY = this.axis.y(0); | ||
const targets = this.brush.target, | ||
error = this.brush.error, | ||
padding = this.brush.innerPadding, | ||
@@ -87,4 +97,3 @@ band = this.axis.y.rangeBand(), | ||
if ((_.typeCheck("array", error) && !error.includes(i)) || | ||
(_.typeCheck("integer", error) && error !== i)) { | ||
if (!this.isErrorColumn(i)) { | ||
while(targetY >= height) { | ||
@@ -115,7 +124,7 @@ let r = _.extend(this.getBarElement(i, j), { | ||
} else { | ||
let width = this.axis.x.rangeBand() * 0.4; | ||
let height = width * 2; | ||
let tick = width * 0.3; | ||
let startX = offsetX - width / 2; | ||
let fontSize = width / 3; | ||
let size = Math.min(this.axis.x.rangeBand(), this.axis.area("height")) * 0.4; | ||
let height = this.axis.area("height") * 0.5; | ||
let tick = size * 0.3; | ||
let startX = offsetX - size / 2; | ||
let fontSize = height / 5; | ||
let yt = y - tick; | ||
@@ -132,5 +141,5 @@ let yht = y - height - tick; | ||
this.canvas.arcTo(startX, yht, startX + round, yht, round); | ||
this.canvas.lineTo(startX + width - round, yht); | ||
this.canvas.arcTo(startX + width, yht, startX + width, yht + round, round); | ||
this.canvas.lineTo(startX + width, yt); | ||
this.canvas.lineTo(startX + size - round, yht); | ||
this.canvas.arcTo(startX + size, yht, startX + size, yht + round, round); | ||
this.canvas.lineTo(startX + size, yt); | ||
this.canvas.fill(); | ||
@@ -144,3 +153,3 @@ | ||
this.canvas.fillStyle = this.chart.theme("equalizerColumnErrorFontColor"); | ||
this.canvas.fillText(this.brush.errorText, height / 2, fontSize / 3, height); | ||
this.canvas.fillText(this.brush.errorText, height / 1.75, fontSize / 3, height); | ||
@@ -176,51 +185,53 @@ this.canvas.restore(); | ||
this.eachData(function (data, i) { | ||
const r = this.chart.getCache(`equalizer_${i}`); | ||
let total = 0; | ||
if (!this.isErrorColumn(i)) { | ||
const r = this.chart.getCache(`equalizer_${i}`); | ||
let total = 0; | ||
for(let j = 0; j < this.brush.target.length; j++) { | ||
total += data[this.brush.target[j]]; | ||
} | ||
for(let j = 0; j < this.brush.target.length; j++) { | ||
total += data[this.brush.target[j]]; | ||
} | ||
if(r != null) { | ||
const tpf = this.chart.getCache(`tpf`, 1); | ||
const status = this.chart.getCache(`equalizer_move_${i}`, { direction: -1, distance: 0 }); | ||
const speed = status.direction == -1 ? UP_SEC_PER_MOVE : DOWN_SEC_PER_MOVE; | ||
if(r != null) { | ||
const tpf = this.chart.getCache(`tpf`, 1); | ||
const status = this.chart.getCache(`equalizer_move_${i}`, { direction: -1, distance: 0 }); | ||
const speed = status.direction == -1 ? UP_SEC_PER_MOVE : DOWN_SEC_PER_MOVE; | ||
status.distance += status.direction * speed * tpf; | ||
status.distance += status.direction * speed * tpf; | ||
// 애니메이션-바 방향 벡터 설정 | ||
if(Math.abs(status.distance) >= MAX_DISTANCE) { | ||
status.direction = 1; | ||
} else if(status.distance >= 0) { | ||
status.direction = -1; | ||
} | ||
// 애니메이션-바 방향 벡터 설정 | ||
if(Math.abs(status.distance) >= MAX_DISTANCE) { | ||
status.direction = 1; | ||
} else if(status.distance >= 0) { | ||
status.direction = -1; | ||
} | ||
// 애니메이션-바 최소/최대 위치 설정 | ||
if(status.distance < -MAX_DISTANCE) { | ||
status.distance = -MAX_DISTANCE; | ||
} else if(status.distance > 0) { | ||
status.distance = 0; | ||
} | ||
// 애니메이션-바 최소/최대 위치 설정 | ||
if(status.distance < -MAX_DISTANCE) { | ||
status.distance = -MAX_DISTANCE; | ||
} else if(status.distance > 0) { | ||
status.distance = 0; | ||
} | ||
const ry = r.y + status.distance + TOP_PADDING; | ||
const ry = r.y + status.distance + TOP_PADDING; | ||
this.canvas.save(); | ||
this.canvas.globalAlpha = r["fill-opacity"]; | ||
this.canvas.strokeStyle = r.fill; | ||
this.canvas.lineWidth = r.height * 0.7; | ||
this.canvas.beginPath(); | ||
this.canvas.moveTo(r.x, ry); | ||
this.canvas.lineTo(r.x + r.width, ry); | ||
this.canvas.closePath(); | ||
this.canvas.stroke(); | ||
this.canvas.save(); | ||
this.canvas.globalAlpha = r["fill-opacity"]; | ||
this.canvas.strokeStyle = r.fill; | ||
this.canvas.lineWidth = r.height * 0.7; | ||
this.canvas.beginPath(); | ||
this.canvas.moveTo(r.x, ry); | ||
this.canvas.lineTo(r.x + r.width, ry); | ||
this.canvas.closePath(); | ||
this.canvas.stroke(); | ||
this.canvas.fillStyle = this.chart.theme("barFontColor"); | ||
this.canvas.font = this.chart.theme("barFontSize") + "px"; | ||
this.canvas.textAlign = "center"; | ||
this.canvas.textBaseline = "middle"; | ||
this.canvas.fillText(total, r.x + r.width/2, ry + TOTAL_PADDING); | ||
this.canvas.fill(); | ||
this.canvas.restore(); | ||
this.canvas.fillStyle = this.chart.theme("barFontColor"); | ||
this.canvas.font = this.chart.theme("barFontSize") + "px"; | ||
this.canvas.textAlign = "center"; | ||
this.canvas.textBaseline = "middle"; | ||
this.canvas.fillText(total, r.x + r.width/2, ry + TOTAL_PADDING); | ||
this.canvas.fill(); | ||
this.canvas.restore(); | ||
this.chart.setCache(`equalizer_move_${i}`, status); | ||
this.chart.setCache(`equalizer_move_${i}`, status); | ||
} | ||
} | ||
@@ -227,0 +238,0 @@ }); |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
4263660
95598