DC - geoChoroplethChart可以与bubbleOverlay结合使用吗?

时间:2016-09-30 10:47:32

标签: dc.js choropleth

此示例(http://dc-js.github.io/dc.js/crime/index.html)看起来很棒,但加拿大地图的路径元素和SVG已手动定义。我想用geoChoroplethChart绘制一张世界地图,然后添加一个bubbleOverlay。

我已经单独尝试了它们,最近尝试了一种compositeChart方法:

  compositeChart.width(1440)
                .height(500)
                .margins({top: 10, right: 50, bottom: 30, left: 60})
                .compose([
                    dc.geoChoroplethChart("#us-chart")
                            .dimension(countries)
                            .projection(projection)
                            .group(countryValue)
                            .colors(d3.scale.category10())
                            .colorDomain([0, 3])
                            .colorCalculator(function (d) { return d ? geoChart.colors()(d) : '#ccc'; })
                            .overlayGeoJson(statesJson.features, "state", function (d) {
                                return d.properties.name;
                            }),

                    dc.bubbleOverlay("#us-chart")
                            .svg(d3.select("#us-chart svg"))
                            .dimension(countries)
                            .group(countryValue)
                            .radiusValueAccessor(function(p) {
                                //console.log(p);
                                return p.val;
                            })
                            .r(d3.scale.linear().domain([0, 4]))
                            .point("Angola",200,200)


                ])


            dc.renderAll();

我有一种偷偷摸摸的感觉,compositeChart只适用于基于网格系统的图表,如折线图和条形图。这是正确的吗?在这种情况下,有没有办法在DC中的一个等值区域添加bubbleOverlay,而不是手动执行?

0 个答案:

没有答案