我有一个使用dc js的复合图表(线条和条形图)

但是,使用奇异条/线dc图表时,比例不会动态变化

为清晰起见,我为y轴(次要和主要两个)制作了5个刻度,但我希望 scales and tickintervals of Y-Axis 根据计算的值动态变化 .

码:

//Composite chart to show 2 metrics
    chart3
    .width(500) // (optional) define chart width, :default = 200
    .height(200) // (optional) define chart height, :default = 200
    .transitionDuration(500) // (optional) define chart transition duration, :default = 500
    // (optional) define margins
    .margins({top: 30, right: 50, bottom: 30, left: 40})
    .dimension(dateDimension) // set dimension
    //.group(rechfreqGroup) // set group
    // (optional) whether chart should rescale y axis to fit data, :default = false
    .elasticY(true)
    // (optional) when elasticY is on whether padding should be applied to y axis domain, :default=0
    .yAxisPadding(100)
    // (optional) whether chart should rescale x axis to fit data, :default = false
    //.elasticX(true)
    // (optional) when elasticX is on whether padding should be applied to x axis domain, :default=0
    .xAxisPadding(500)
    // define x scale
    .x(d3.scale.ordinal().domain(["DURING","POST1"]))
    .xUnits(dc.units.ordinal)
    //.renderHorizontalGridLines(true)
    //.renderVerticalGridLines(true)
    .legend(dc.legend().x(200).y(5).itemHeight(10).gap(3))
    .title(function(d) { return "Revenue : "  + d3.round(d.value.rechtotal/d.value.new_count,2) + " Frequency : " + 
    d3.round(d.value.rechfreq/d.value.new_count,2) ; })
    .yAxisLabel("Revenue (in $)")
    .rightYAxisLabel("Frequency")
    .brushOn(false)
    // compose sub charts, currently composite chart only supports line chart & bar chart
    ._rangeBandPadding(1) //workaround to fix visual stuff (dc js issues)
    .compose([

        dc.barChart(chart3).group(rechrevGroup,"Average Revenue").gap(10).centerBar(true).xUnits(function(){return 10;}).valueAccessor(function (p) {
        return (p.value.rechtotal / p.value.new_count) ; 
        //return p.value.count > 0 ? p.value.rechtotal / p.value.new_count : 0;
        }),
        // you can even include stacked bar chart or line chart in a composite chart
        dc.lineChart(chart3).group(rechfreqGroup,"Average Frequency").brushOn(false).useRightYAxis(true).colors('#000000').valueAccessor(function (p) {
        return (p.value.rechfreq / p.value.new_count) ;
        })
    ])
    .yAxis().ticks(5);

    chart3.rightYAxis().ticks(5);

是否可以根据计算的值进行动态缩放(此处为Y轴)?如果没有,我可以至少设置tickValues等吗?

关于动态扩展和/或替代方案的任何方法/建议都将受到高度赞赏

UPDATE

用我完全相同的代码创建了一个小提琴here

2个问题:

  • 图表的动态缩放在此小提琴中完美地使用/不使用elasticY(true) . (不过我在我正在构建的仪表板中的代码和图表中工作!)为什么会发生这种情况?我错过了什么/在这里做了一些根本错误的事情吗?

  • brushOn(false)不起作用,条形图是可点击的,它们在小提琴中被选中(在我的项目中,它们被选中并且交叉滤波器也相应地过滤所有其他图形)如何关闭选择?或者,针对特定图表进行交叉过滤?

如果您有解决这些问题的任何解决方案/方法,请与我们联系