dc.js - 监听图表组渲染 [英] dc.js - Listening for chart group render

查看:29
本文介绍了dc.js - 监听图表组渲染的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试重构一些我编写的自定义 d3 代码,以通过引入 dc.js 来呈现一系列交叉过滤器驱动的图表.

I'm trying to refactor some custom d3 code that I wrote to render a series of crossfilter-driven charts by bringing in dc.js.

我的主要问题是我有一些 dc.js 不支持的图表类型(例如 Sunburst 分区) 并且我正在尝试弄清楚如何将它们与 dc.js 图表组一起呈现.

My main problem is that I have some chart types that are not supported by dc.js (e.g. a Sunburst Partition) and I'm trying to figure out how to render them in conjunction with a dc.js chart group.

过滤单个 dc.js 图表将自动呈现/重绘属于相同的所有其他图表 chartGroup.是否有可能以某种方式连接到该全局重新渲染事件中,以便我可以同时重新绘制非直流图表?

Filtering a single dc.js chart will automatically render / redraw all other charts belonging to the same chartGroup. Is it possible to somehow hook into that global re-render event, so that I can re-draw the non-dc charts at the same time?

我知道每个图表上都有听众,例如chart.on("postRender", function(chart){...}) 但似乎没有办法重新渲染一组图表.有没有好的模式可以实现这一点?

I understand that there are listeners on each individual chart, e.g. chart.on("postRender", function(chart){...}) but there doesn't seem to be a way to hook into re-rendering a group of charts. Is there a good pattern by which this could be accomplished?

推荐答案

执行此操作的正确"方法是使用 dc.registerChart

The "right" way to do this is to register your chart in the dc registry with dc.registerChart

您只需要在某个对象(您的图表或包装器)上实现 .redraw().render(),并将该对象作为第一个参数传递.

You just need to implement .redraw() and .render() on some object (your chart or a wrapper), and pass that object as the first argument.

将它与它应该响应的图表放在同一组(第二个参数)中.

Put it in the same group (second arg) as the charts it should respond to.

render() 从头开始​​创建 dom 元素,redraw() 在数据改变时更新它们.

render() creates the dom elements from scratch, and redraw() updates them when the data changes.

根据图表的使用方式,您可能还需要实现 .filterAll().anchorName()

Depending on how the chart is used, you may also have to implement .filterAll() and .anchorName()

这篇关于dc.js - 监听图表组渲染的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆