我讨厌创建一个新帖子来问这个问题,但由于我还是新的,我还不能对帖子发表评论。
我基本上和dc.js - min value from group per day
有同样的问题但由于jsfiddle不再,我无法看到他们如何解决这个问题。
var data = [
{category: 'A', ..., amount: '13', categoryCount: 1},
{category: 'A', ..., amount: '13', categoryCount: 0},
{category: 'B', ..., amount: '10', categoryCount: 1},
{category: 'A', ..., amount: '3', categoryCount: 1},
{category: 'C', ..., amount: '27', categoryCount: 1},
{category: 'A', ..., amount: '11', categoryCount: 1},
{category: 'B', ..., amount: '18', categoryCount: 2},
{category: 'C', ..., amount: '19', categoryCount: 1},
{category: 'C', ..., amount: ' ', categoryCount: 1},
{category: 'C', ..., amount: '22', categoryCount: 1}
];
我希望有一个区域图,其中包含每个类别的最小(和最大)值。
我现在有
var bar_graph = dc.barChart("#bar_chart");
var bar_graphDim = ndx.dimension(function(d) {return d.category;});
var bar_graphGroup = bar_graphDim.group().reduceSum(d.categoryCount);
var dateDimGroup = reductio().min(function (d) { return +d.amount; })(bar_graphDim.group());
var dateDimFGroup = remove_empty_bins(dateDimGroup);
bar_graph
.width(150).height(60)
.dimension(bar_graphDim)
.group(dateDimFGroup)
.valueAccessor(function(d) {return d.value.min;}) //added a solution
.renderHorizontalGridLines(true)
.gap(2)
.x(d3.scale.ordinal())
.xUnits(dc.units.ordinal)
.elasticY(true)
.elasticX(true)
.yAxisLabel("counts");
var bar_graphGroupMax = bar_graphDim.group().reduceSum(d.categoryCount);
var dateDimGroupMax = reductio().min(function (d) { return +d.amount; })(bar_graphDim.group());
var dateDimFGroupMax = remove_empty_bins(dateDimGroupMax);
bar_graphMax
.width(150).height(60)
.dimension(bar_graphDim)
.group(dateDimFGroupMax)
.valueAccessor(function(d) {return d.value.max;})
.renderHorizontalGridLines(true)
.gap(2)
.x(d3.scale.ordinal())
.xUnits(dc.units.ordinal)
.elasticY(true)
.elasticX(true)
.yAxisLabel("counts");
答案 0 :(得分:1)
你有
var dateDimGroup = reductio().min(function (d) { return d.amount; }(dateDim.group());
我认为即使执行,也不是吗?我希望你有:
var dateDimGroup = reductio().min(function (d) { return +d.amount; })(dateDim.group());