结合d3.js和Backbone.js的 [英] Combining d3.js and backbone.js

查看:89
本文介绍了结合d3.js和Backbone.js的的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的工作,结合所有的Backbone.js的可视化d3.js成一个单一的网页应用程序的项目。因为我有很多的可视化,如柱状图,饼图,等等,我想知道这个问题的最佳方法是什么。

I am working on a project which combines all the d3.js visualizations with backbone.js into a single page application. Since I have many visualizations such as bar chart, pie chart, and so on, i was wondering what the best approach to this problem is.

例如,可以说我有两个柱状图和饼状图。我应该把所有的利润集,秤,渲染所有的图表一起在一个视图中的所有数据?由于有两种不同类型的图形,应该是什么模式?

For instance, lets say I have a two bar charts, and a pie chart. Should I put all set margins, scales, render all data for all the charts together in a view? Since there are two different types of graphs, what should be the model?

我应该去查看,模型,控制,收集,等等?

What should go to View, Model, Controller, Collection, and so on?

由于提前,

推荐答案

我看着结合D3和骨干一点,有一些现有的解决方案在那里:

I've looked into combining D3 and Backbone a little and there are a few existing solutions out there:

概述presentation

<一个href=\"https://speakerdeck.com/sameersegal/combining-d3-dot-js-plus-backbone-dot-js-to-create-quick-realtime-graphs\">Short教程结合骨干和放大器; D3

更长的讨论

Longer discussion on marrying Backbone and D3

一种与D3 整合一堆JS库

我还发现在GitHub上一个库,但它似乎没有得到支持......

I also found a library on GitHub but it didn't seem to be supported...

在最后,所有这些真的很满意我,所以我开发我自己的骨干机型,集合&安培;意见。我设置:

In the end, none of these really satisfied me so I developed my own Backbone models, collections & views. I set up:

ChartPoint 模型 - X&安培; Y坐标和点标签

ChartPoint Model - X & Y coordinate and a point label

ChartSeries中系列 - 定义全图ChartPoints集

ChartSeries Collection - Collection of ChartPoints that define the full chart

ChartBaseView - 一个观点,即除$ P $点以上数据,处理事件,绘制轴等一般功能

ChartBaseView - A view that interprets the data above, handles events, draws axes and other general functions

BarChartView LineChartView PieChartView 等。 - 渲染你想要的图表类型的具体意见。大部分的D3 code的放在这里。

BarChartView, LineChartView, PieChartView, etc. - Specific views for rendering the type of charts you want. Most of your D3 code goes here.

不是说这是正确的方式做到这一点......只是我的方式。

Not saying this is the "right" way to do it... just my way.

这篇关于结合d3.js和Backbone.js的的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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