vizabi-barchart-ds
Advanced tools
Comparing version 1.0.2 to 1.0.3
@@ -11,3 +11,3 @@ { | ||
"name": "vizabi-barchart-ds", | ||
"version": "1.0.2", | ||
"version": "1.0.3", | ||
"dependencies": { | ||
@@ -14,0 +14,0 @@ "vizabi": "^0.21.0-20" |
@@ -13,3 +13,3 @@ const { | ||
// POP BY AGE CHART COMPONENT | ||
const BarChartDS = Component.extend({ | ||
const BarChartDS = Component.extend("barchartds", { | ||
@@ -80,3 +80,3 @@ /** | ||
_this._reorderBars(); | ||
_this._updateEntities(); | ||
_this._updateEntities(true); | ||
_this.updateBarsOpacity(); | ||
@@ -287,2 +287,3 @@ }); | ||
this.labels = this.graph.select(".vzb-bc-labels"); | ||
this.labels.select(".vzb-bc-age").attr("y", -10); | ||
@@ -355,2 +356,3 @@ this.title = this.element.select(".vzb-bc-title"); | ||
this.KEYS = utils.unique(this.model.marker._getAllDimensions({ exceptType: "time" })); | ||
this.side = this.model.marker.label_side.getEntity(); | ||
@@ -478,3 +480,3 @@ this.SIDEDIM = this.side.getDimension(); | ||
const stacks = this.model.marker.getKeys(stackDim); | ||
const stacks = this.model.marker.color.use == "indicator" ? [] : this.model.marker.getKeys(stackDim); | ||
const stackKeys = utils.without(stacks.map(m => { | ||
@@ -518,3 +520,7 @@ if (m[stackDim] == _this.totalFieldName) _this.dataWithTotal = true; | ||
const domain = this.yScale.domain(); | ||
domain.sort((a, b) => d3.ascending(_this.frameOrder[a] || 0, _this.frameOrder[b] || 0)); | ||
const sideKeys = this.sideKeys; | ||
domain.sort((a, b) => { | ||
const result = d3.ascending(_this.frameOrder[a] || 0, _this.frameOrder[b] || 0); | ||
return result !== 0 ? result : d3.ascending(_this.frameAxisX[sideKeys[0]][a] || 0, _this.frameAxisX[sideKeys[0]][b] || 0); | ||
}); | ||
this.yScale.domain(domain); | ||
@@ -739,6 +745,4 @@ }, | ||
.attr("class", (d, i) => "vzb-bc-side " + "vzb-bc-side-" + (!i != !_this.twoSided ? "right" : "left")) | ||
.merge(this.sideBars); | ||
.merge(this.sideBars); | ||
this.sideBars.attr("transform", (d, i) => i ? ("scale(-1,1) translate(" + _this.activeProfile.centerWidth + ",0)") : ""); | ||
if (reorder) { | ||
@@ -751,14 +755,14 @@ this.sideBars.attr("transform", (d, i) => i ? ("scale(-1,1) translate(" + _this.activeProfile.centerWidth + ",0)") : ""); | ||
this.stackBars = this.sideBars.selectAll(".vzb-bc-stack").data((d, i) => { | ||
const stacks = _this.stacked ? _this.stackKeys : [_this.totalFieldName]; | ||
return stacks.map(m => { | ||
const stacks = _this.stacked ? _this.stackKeys : [_this.totalFieldName]; | ||
return stacks.map(m => { | ||
const r = {}; | ||
r[ageDim] = d[ageDim]; | ||
r[shiftedAgeDim] = d[shiftedAgeDim]; | ||
r[sideDim] = d[sideDim]; | ||
r[stackDim] = m; | ||
r[prefixedSideDim] = d[prefixedSideDim]; | ||
r[prefixedStackDim] = m; | ||
return r; | ||
}); | ||
}, d => d[prefixedStackDim]); | ||
r[ageDim] = d[ageDim]; | ||
r[shiftedAgeDim] = d[shiftedAgeDim]; | ||
r[sideDim] = d[sideDim]; | ||
r[stackDim] = m; | ||
r[prefixedSideDim] = d[prefixedSideDim]; | ||
r[prefixedStackDim] = m; | ||
return r; | ||
}); | ||
}, d => d[prefixedStackDim]); | ||
@@ -808,30 +812,22 @@ this.stackBars.exit().remove(); | ||
this.entityLabels = this.labels.selectAll(".vzb-bc-label") | ||
.data(this.markers); | ||
//exit selection | ||
this.entityLabels.exit().remove(); | ||
// this.entityLabels = this.labels.selectAll(".vzb-bc-label") | ||
// .data(this.markers, d => d[ageDim]); | ||
// //exit selection | ||
// this.entityLabels.exit().remove(); | ||
this.entityLabels.enter().append("g") | ||
.attr("class", "vzb-bc-label") | ||
.attr("id", d => "vzb-bc-label-" + d[shiftedAgeDim] + "-" + _this._id) | ||
.append("text") | ||
.attr("class", "vzb-bc-age") | ||
.merge(this.entityLabels) | ||
.each((d, i) => { | ||
const yearOlds = _this.translator("popbyage/yearOlds"); | ||
// const entityLabels = this.entityLabels.enter().append("g") | ||
// .attr("class", "vzb-bc-label") | ||
// .attr("id", d => "vzb-bc-label-" + d[shiftedAgeDim] + "-" + _this._id) | ||
// entityLabels.append("text") | ||
// .attr("class", "vzb-bc-age") | ||
// .attr("y", (d, i) => firstBarOffsetY - _this.yScale(d[shiftedAgeDim]) - 10); | ||
let age = parseInt(d[ageDim], 10); | ||
// this.entityLabels = entityLabels.merge(this.entityLabels); | ||
// // .style("fill", function(d) { | ||
// // var color = _this.cScale(values.color[d[ageDim]]); | ||
// // return d3.rgb(color).darker(2); | ||
// // }); | ||
if (groupBy > 1) { | ||
age = age + "-to-" + (age + groupBy - 1); | ||
} | ||
// if (reorder) this.entityLabels.selectAll(".vzb-bc-age").attr("y", (d, i) => firstBarOffsetY - _this.yScale(d[shiftedAgeDim]) - 10); | ||
d["text"] = age + yearOlds; | ||
}) | ||
.attr("y", (d, i) => firstBarOffsetY - _this.yScale(d[shiftedAgeDim]) - 10); | ||
// .style("fill", function(d) { | ||
// var color = _this.cScale(values.color[d[ageDim]]); | ||
// return d3.rgb(color).darker(2); | ||
// }); | ||
if (duration) { | ||
@@ -856,3 +852,3 @@ this.year.transition().duration(duration).ease(d3.easeLinear) | ||
_this.model.marker.highlightMarker(d); | ||
_this._showLabel(d); | ||
//_this._showLabel(d); | ||
}, | ||
@@ -884,2 +880,4 @@ mouseout(d, i) { | ||
_this.labels.selectAll(".vzb-hovered").classed("vzb-hovered", false); | ||
} else { | ||
_this._showLabel(_this.model.marker.highlight[0]); | ||
} | ||
@@ -894,16 +892,19 @@ }, | ||
const stackDim = _this.STACKDIM; | ||
const shiftedAgeDim = "s_age"; | ||
const KEYS = this.KEYS; | ||
const left = _this.sideKeys.indexOf(d[sideDim]); | ||
const label = _this.labels.select("#vzb-bc-label-" + d[shiftedAgeDim] + "-" + _this._id); | ||
label.selectAll(".vzb-bc-age") | ||
const label = _this.labels.select(".vzb-bc-label"); | ||
const bar = _this.bars.select(".vzb-bc-bar-" + d[ageDim]); | ||
//const label = _this.labels.select("#vzb-bc-label-" + d[ageDim] + "-" + _this._id); | ||
label.attr("transform", bar.attr("transform")) | ||
.select(".vzb-bc-age") | ||
.text(textData => { | ||
//var total = _this.ui.chart.inpercent ? _this.totalValues[d[sideDim]] : 1; | ||
let text = _this.stackKeys.length > 1 ? _this.stackItems[d[stackDim]] : textData.text; | ||
text = _this.twoSided ? text : textData.text + " " + _this.stackItems[d[stackDim]]; | ||
const value = _this.xScale.invert(d["width_"]); | ||
//var value = (_this.dataWithTotal || _this.stacked) ? _this.values1.axis_x[d[shiftedAgeDim]][d[sideDim]][d[stackDim]] / total : _this.xScale.invert(d["width_"]); | ||
return text + ": " + formatter(value); | ||
}) | ||
.attr("x", (left ? -1 : 1) * (_this.activeProfile.centerWidth * 0.5 + 7)) | ||
//var total = _this.ui.chart.inpercent ? _this.totalValues[d[sideDim]] : 1; | ||
let text = _this.stackKeys.length > 1 ? _this.stackItems[d[stackDim]] : _this.frame.label_age[d[ageDim]]; | ||
text = _this.twoSided ? text : text + " " + _this.stackItems[d[stackDim]]; | ||
const value = utils.getValueMD(d, _this.frameAxisX, KEYS);//_this.xScale.invert(d["width_"]); | ||
//var value = (_this.dataWithTotal || _this.stacked) ? _this.values1.axis_x[d[shiftedAgeDim]][d[sideDim]][d[stackDim]] / total : _this.xScale.invert(d["width_"]); | ||
return text + ": " + formatter(value); | ||
}) | ||
.attr("x", (left ? -1 : 1) * (_this.activeProfile.centerWidth * 0.5 + 7)) | ||
.classed("vzb-text-left", left); | ||
@@ -910,0 +911,0 @@ |
@@ -1,1 +0,1 @@ | ||
module.exports = require("vizabi-tool-bundler").bind(null, "BarChartDS", "barchart-ds", __dirname); | ||
module.exports = require("vizabi-tool-bundler").bind(null, "BarChartDS", "barchart-ds", __dirname); |
Sorry, the diff of this file is not supported yet
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 1 instance in 1 package
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
54266
11
1124
3