正如标题所提到的,我们无法将鼠标悬停在 path.area 后面的点上。
情况如下
如果我们将鼠标悬停在蓝线和黄线上,我们可以获得工具提示,但是如果我们将鼠标悬停在红线上,我们只能从第一个点和最后一个点获得工具提示。
代码如下:
let nix = crossfilter();
timeseriesFiltered.forEach(ts => {
ndx.add(ts.values.map(function(d) {
let temp = JSON.parse(JSON.stringify(objTemplate));
temp[ts.place] = d.value;
temp.date = new Date(d.timestamp);
return temp;
}));
});
let dimDate = ndx.dimension(dc.pluck('date'));
let lineChartGroups = [];
timeseriesFiltered.forEach((ts, index) => {
let group = dimDate.group().reduceSum(dc.pluck(ts.place));
let lineChart = dc.lineChart(composite)
.dimension(dimDate)
.renderDataPoints(true)
.renderArea(true)
.defined(d => {
return d.y != 0;
})
.colors(this.colors[index])
.group(group, this.setName(ts.place));
lineChartGroups.push(lineChart);
})
let chart = composite
.width(width)
.height(300)
.margins({top: 30, right: 60, bottom: 30, left: 60})
.x(d3.scaleTime().domain([new Date(minDate), new Date(maxDate)]))
.yAxisLabel(timeseriesFiltered[0].unit)
.elasticY(true)
.mouseZoomable(true)
.brushOn(false)
.clipPadding(10)
.legend(dc.legend().x(80).y(20).itemHeight(13).gap(5))
._rangeBandPadding(1)
.compose(lineChartGroups);
chart.render();
我们尝试通过使用以下语句来提高所有圆点:
d3.selectAll('circle.dot').raise();
但它没有用。有什么建议吗?
我不确定renderArea
在复合图表中使用它是否是一个好主意;正如你所看到的,颜色混在一起变成了棕色,并不清楚它应该传达什么。
我认为renderArea
使用堆叠图表效果更好,其中每种颜色覆盖的区域都具有某种意义。
也就是说,解决您所看到的问题非常容易。
提高点不起作用的原因是因为复合图表的每个子项都在自己的图层中。因此,提高圆点只会使它们位于该图表的顶部(它们已经位于该位置)。
相反,您可以禁用填充区域的鼠标交互:
path.area {
pointer-events: none;
}
由于填充区域之前不是交互式的,因此不应损失太多,但您可能希望更加保守并使用选择器将规则限制到特定图表 #composite-chart path.area
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句