我们在一个实时数据环境中使用c3图表库的条形图功能。这导致了一个问题,即如果用户悬停在一个条形图上,条形图本身会更新,但是显示的工具提示却没有更新。有没有一种方法可以更新/重新加载工具提示?
@更新1:
抱歉回复晚了。基本上,我们有一个观察者监听数据变化。这将触发一个名为reload的方法,其中包含以下行(数据的外观如评论中所示):
![enter image description here](https://istack.dev59.com/9mvpM.webp)
chart.load({
xs: xs, // AmberViolation:"facilityId",BlueViolation:"facilityId",RedViolation:"facilityId"
columns: columns, // [["facilityId", "SUB-GTW"],["RedViolation", 0],["BlueViolation", 2],["AmberViolation", 0]]
unload: _.difference(drawnChartYCols, nextDrawColumns),
types: types, // AmberViolation:"bar",BlueViolation:"bar",RedViolation:"bar"
colors: colors,
done: function () {
if (columns.length && columns[0].length > 10) {
chart.zoom([0, 11]);
d3.select(element[0]).selectAll('svg > g').filter(function(d, i) { return i === 1 }).attr('display', null);
chart.resize({width: $scope.width, height: $scope.height});
d3.select(element[0]).select('.extent').attr('x', 0);
} else {
chart.unzoom();
d3.select(element[0]).selectAll('svg > g').filter(function(d, i) { return i === 1 }).attr('display', 'none');
chart.resize({width: $scope.width, height: $scope.height + 70});
}
}
});
chart.groups([groups]);// ["RedViolation","BlueViolation","AmberViolation"]
@更新2:
您甚至可以在http://c3js.org/samples/chart_bar_stacked.html上看到这种行为。 只要在数据更新时悬停在其中一个条形图上并让鼠标停留在那里,工具提示就不会更新。 只有再次移动鼠标才会刷新。
@更新3:由于即使在我创建的c3图表示例中也会出现此问题,因此我在Github上创建了一个错误报告:https://github.com/c3js/c3/issues/2307
.load(args)
函数来加载新数据吗?http://c3js.org/reference.html#api-load - Andrew Lohr