react 数据可视化

Data visualisation and application technologies have evolved greatly over the past decade. Two of the most popular web-based technologies for this are D3.js and React.js and both began as separate projects in 2011. Now, after nearly 10 years, there is finally an elegant way to have these two technologies work together to deliver both an exciting data visualisation experience and sustainable development workflow.

在过去的十年中,数据可视化和应用技术得到了巨大的发展。 两种最流行的基于Web的技术是D3.js和React.js,它们都在2011年作为单独的项目开始。如今,在将近10年之后,终于有了一种优雅的方式来使这两种技术协同工作以交付令人兴奋的数据可视化体验和可持续发展工作流程。

D3 is an excellent library for rendering data visualisation — this should be preserved by separating D3 implementation from React.

D3是用于呈现数据可视化的优秀库-应该通过将D3实现与React分开来保留它。

Understanding this workflow is important for developers, designers and anyone involved with the process of creating data visualisations as it can help improve the experience and reduce the effort to create it. Having two workflows might seem contradictory to this second point and throughout this piece I will attempt to illustrate why this is not the case.

对于开发人员,设计人员以及参与数据可视化过程的任何人来说,了解此工作流程都很重要,因为它可以帮助改善体验并减少创建数据的工作量。 拥有两个工作流程似乎与第二点矛盾,在整篇文章中,我将尝试说明为什么情况并非如此。

D3和React之间的根本区别 (The fundamental difference between D3 and React)

Both D3 and React provide their own DOM Manipulation API – adding, updating and deleting HTML. D3 offers life cycle events to match the DOM change operation (enter, update and exit) with method chaining syntax that is designed to directly alter the HTML elements. Whereby React provides an entirely different concept of a Virtual DOM with JSX syntax and React controls how this translates to the real HTML elements.

D3和React都提供了自己的DOM操作API-添加,更新和删除HTML。 D3提供了生命周期事件,以使用旨在直接更改HTML元素的方法链接语法来匹配DOM更改操作(输入,更新和退出)。 因此,React用JSX语法提供了一个完全不同的虚拟DOM概念,而React控制着它如何转换为真实HTML元素。

React和视觉设计的演变使您相信一切都应该是一个React组件 (React and visual design evolution leads you to believe everything should be a React component)

The powerful layer of abstraction from React provides an excellent development workflow such that parts of the page can be separated into individual components. This workflow also matches how web design has evolved from static full page designs into component based style guides – and more recently design systems. React has proved to be so useful at describing these modularised systems that the immediate reaction from developers was to bring other technologies such as D3 and abstract them into React components.

React强大的抽象层提供了出色的开发工作流程,因此页面的各个部分可以分为单独的组件。 此工作流还与Web设计如何从静态的整页设计演变为基于组件的样式指南以及最新的设计系统相匹配。 事实证明,React在描述这些模块化系统方面非常有用,以至于开发人员的立即React就是将其他技术(例如D3)引入到React组件中。

One approach would be using React to handle the DOM and styling and using D3 to only handle the math. This approach is what the evolution of React and visual design systems would lead us to believe is the most appropriate solution. However, it is not the case even though as of writing it is still quite a popular approach and many libraries use it today including the popular Recharts library. As these libraries will attest there are many benefits to writing all the DOM markup in JSX — such as being able to separate the parts of a data visualisation graphic as you would any other element on the page.

一种方法是使用React处理DOM和样式,并使用D3仅处理数学。 这种方法正是React和视觉设计系统的发展将使我们相信这是最合适的解决方案。 但是,事实并非如此,尽管在编写之时它仍然是一种非常流行的方法,并且今天许多图书馆都在使用它,包括流行的Recharts库。 正如这些库所证明的那样,用JSX编写所有DOM标记有很多好处-例如,能够像页面上的任何其他元素一样分离数据可视化图形的各个部分。

When pausing for a moment, this approach doesn’t actually align to how data visualisations are created — a visualisation cannot always be broken down into smaller parts as each part relates to each other much more closely than the other parts of a web page. There are also some significant downsides that involve needing to reimplement complex concepts in D3 such as data updates, transitions and animations. Another issue is that writing in JSX requires translating examples and references for D3 from an entirely different language — as most D3 examples are surprisingly described in the D3 method chaining syntax style and directly reference D3 APIs. All of this is to say that this approach is not respecting the fundamental difference between the two technologies.

暂停片刻后,此方法实际上与数据可视化的创建方式不符-可视化不能总是分解成较小的部分,因为每个部分之间的相互关系比网页的其他部分紧密得多。 还有一些重大的缺点,涉及需要在D3中重新实现复杂的概念,例如数据更新,过渡和动画。 另一个问题是,用JSX编写代码需要从完全不同的语言翻译D3的示例和引用-因为大多数D3示例都以D3方法链语法样式直接描述了D3 API。 所有这些都是说这种方法没有尊重两种技术之间的根本区别。

如何将D3实现与React分开 (How to separate D3 implementation from React)

Another approach to working with D3 is to only render a root node in React and use D3 to control the visualisation with its own DOM Manipulation API. Data and events will still need to be transmitted between React and D3 and this can be achieved concisely with React Hooks.

使用D3的另一种方法是仅在React中渲染一个根节点,并使用D3通过其自己的DOM Manipulation API控制可视化。 仍然需要在React和D3之间传输数据和事件,这可以通过React Hooks简洁地实现。

The immediate benefits of this approach include each technology having a single responsibility, reference material for D3 is the same as the project code and any data visualisation presentation is possible with minimal code. This approach also makes the code more sustainable as D3 is decoupled from React and the two technologies are free to evolve independently with the effort to adopt new features from either very minimal on the project.

这种方法的直接好处是,每种技术都负有单一责任,D3的参考资料与项目代码相同,并且只需最少的代码就可以进行任何数据可视化演示。 当D3与React分离时,这种方法还使代码更具可持续性,并且两种技术可以自由地独立发展,并努力从项目中的任何一个最小的方面采用新功能。

When adopting this approach it’s important to understand D3 elements can’t be separated in components in the same way they can in React. This is a side-effect of how the D3 lifecycle is designed, where richer experiences are built by describing together all the elements bound to the data. Each visualisation should be treated as a closed system. If React components are Lego bricks then D3 visualisations wrapped in React are light bricks.

当采用这种方法时,重要的是要了解D3元素不能像在React中一样被分离在组件中。 这是D3生命周期设计方式的副作用,在D3生命周期中,通过一起描述绑定到数据的所有元素来构建更丰富的体验。 每种可视化都应视为封闭系统。 如果React组件是乐高积木,那么包裹在React中的D3可视化效果就是轻质砖。

结论 (Conclusion)

As with all things in software development we should always strive to design systems and write code in a way that can adopt change as efficiently as possible. React and D3 have both evolved with each technology delivering excellent frameworks for their respective purposes. Projects will be able to adopt new features in each technology by respecting these frameworks with the independence they deserve.

与软件开发中的所有事物一样,我们应始终努力设计系统并编写代码,以尽可能有效地采用变更。 React和D3都随着每种技术的发展而发展,它们为各自的目的提供了出色的框架。 通过尊重这些框架应具有的独立性,项目将能够在每种技术中采用新功能。

进一步阅读 (Further reading)

If you’re just starting out with D3 then I highly recommend Adam Janes on the David Walsh blog: 5 Crucial Concepts for Learning d3.js and How to Understand Them

如果您只是从D3开始,那么我强烈推荐David Walsh博客上的Adam Janes:学习d3.js和如何理解它们的5个关键概念。

Karol Stopya has a practical guide to separating D3 from React: https://link.medium.com/a9cjWGWhT9

Karol Stopya拥有从React分离D3的实用指南: https ://link.medium.com/a9cjWGWhT9

This snippet by Alex Johnson does well to cover the pros and cons for different approaches to D3 and React: Working with React and D3 together · GitHub

Alex Johnson的这段代码很好地介绍了D3和React不同方法的优缺点:一起使用React和D3·GitHub

翻译自: https://medium.com/seek-blog/creating-data-visualisations-with-d3-and-react-in-2020-609152db1af9

react 数据可视化


http://www.taodudu.cc/news/show-4286918.html

相关文章:

  • rdms系统_什么是关系数据库管理系统(RDMS)?
  • 按照日期:蓝桥杯真题、洛谷题单、力扣题单汇总
  • NOIP历年第二轮入门组真题集合
  • 数据类型、变量、字符串(工匠工坊第二课)
  • 历年CSP-J(NOIP普及组)分类汇总目录
  • Gradio实现算法可视化
  • c语言若输入错误的是,C语言新人常见问题与错误
  • 国民统计概论考试能用计算机吗,统计考试《国民经济统计概论》试题
  • JS笔记:实现网页税收表
  • 01改变世界:机械之美——机械时期的计算设备
  • 如何用计算机算p,‎App Store 上的“计算器++P”
  • Java 报表工具
  • 报表工具之ireport
  • 什么是报表工具?和 EXCEL 有什么区别?
  • adb连接夜神模拟器和连接夜神多开的方法
  • 夜神模拟器抓取数据包
  • 绝对管用的eclipse连接夜神模拟器方法
  • 安装VMware Workstation 16.1
  • VMware Workstation共享磁盘建立
  • 带你一文搞懂VMware Workstation的三种网络模式
  • 虚拟机介绍与使用(VMware Workstation)
  • 深度学习基础:评价标准——TP、FN、FP、TN、AP、MAP
  • 【经典收藏】深度技术ghost官方原版XP系统sp3下载地址 ...
  • 深度技术GhostXP专业版V9.0之初体验
  • Unity-Creating Project folder failed!
  • eclipse 提示destination folder must be accessible
  • VS code编辑器出现open a floder or workspace... (File -> Open Folder)错误
  • No toolchains found in the NDK toolchains folder for ABI with prefix: arm-linux-androideabi
  • error: The folder you are executing pip from can no longer be found.
  • C# WinForm 文件夹选择控件 folderBrowserDialog 的应用实例

react 数据可视化_使用d3创建数据可视化并在2020年做出React相关推荐

  1. python数据透视_用pythonwin32com创建数据透视图

    我设法做到了import win32com.client import os Excel = win32com.client.gencache.EnsureDispatch('Excel.Applic ...

  2. 时间序列数据卡尔曼滤波_使用Highcharts和InfluxDB可视化时间序列数据

    实时绘制大量带时间戳的数据往往是一项棘手的任务,需要相当多的技巧和过多的耐心.幸运的是,我们已经有了InfluxData平台来为我们提供开箱即用的许多困难.我们可以高效,安全地收集和存储数据,构建可视 ...

  3. python做大屏数据可视化_超强大!Python 可视化这款大屏就够了!

    对于从事数据领域的小伙伴来说,当需要阐述自己观点.展示项目成果时,我们需要在最短时间内让别人知道你的想法.我相信单调乏味的语言很难让别人快速理解.最直接有效的方式就是将数据进行可视化展现. 提到数据可 ...

  4. python 3d大数据可视化_基于Python的数据可视化库pyecharts介绍

    什么是pyecharts? pyecharts 是一个用于生成 Echarts 图表的类库. echarts 是百度开源的一个数据可视化 JS 库,主要用于数据可视化.pyecharts 是一个用于生 ...

  5. mysql数据库命令 单选_mysql中创建数据库命令是?_学小易找答案

    [单选题]NH4NO2分解得氮气和水,在23°C,95549.5 Pa 条件下,用排水集气法收集到57.5 cm3氮气.已知水的饱和蒸气压为2813.1 Pa,则干燥后氮气的体积为() [填空题]在相 ...

  6. navicat mysql 建表语句_Navicat for MySQL怎么/如何创建数据表?Navicat for MySQL创建数据表教程_斗蟹游戏网...

    [斗蟹攻略]Navicat for MySQL是针对MySQL数据库管理而研发的管理工具,创建数据表是其最基本操作,下面就由斗蟹小编介绍Navicat for MySQL创建数据表的方法. Navic ...

  7. 不平衡数据采样_过度采样不平衡数据的5种打击技术

    不平衡数据采样 Imbalance data is a case where the classification dataset class has a skewed proportion. For ...

  8. excel数据透视_取消透视Excel数据的快速方法

    excel数据透视 Before you can build a flexible pivot table, you might need to rearrange the data. For exa ...

  9. python大数据论坛_干货 | Python+大数据计算平台,PyODPS架构手把手教你搭建

    数据分析和机器学习 大数据基本都是建立在Hadoop系统的生态上的,其实一个Java的环境.很多人喜欢用Python和R来进行数据分析,但是这往往对应一些小数据的问题,或者本地数据处理的问题.如何将二 ...

最新文章

  1. 实践微服务六年,我获得了这些心得体会
  2. matlab 12脉波变压器,12脉波中频炉专用变压器外形尺寸
  3. MySQL-数据库三大范式
  4. C# 窗体实例化一次
  5. 下列有关python语言的说法正确的是-下列有关对Python 语言的叙述中,不正确的是【 】。...
  6. 20135313_exp5
  7. 【HDU - 1241】Oil Deposits (连通块问题 属于求大海中的岛屿个数 类似问题)
  8. OSPF——GRE Tunnel(含配置命令)详解
  9. 车辆抵押贷款风险分析
  10. 正则表达式(待补充)
  11. 团队博客作业-Week3
  12. osg加载osgb数据_PCM点云数据处理软件功能使用第十七弹
  13. mac 安装 JDK
  14. Bootstrap框架——栅格系统
  15. 工控网络安全性测试解决方案
  16. 如何用vba把word文档的每页单独保存为一个word文档
  17. nvidia驱动安装,屏幕偏移调整,及屏幕刷新率解决办法(摘自:中国Linux公社)
  18. 统计各个部门对应员工涨幅的次数总和,给出部门编码dept_no、部门名称dept_name以及次数sum
  19. 苏宁云宣布下线公有云服务!
  20. 华为Android 10手机微信小程序无法调起的问题解决办法

热门文章

  1. python 列表作业
  2. 课程理论知识、教学实施
  3. emlog橙子采集插件V2.2修复版 内附视频教程
  4. mybatis中的动态sql
  5. 可编程中控 c 语言,可编程中控是什么?如何应用?
  6. php地区代码吗,将国家/地区名称转换为国家/地区代码缩写php
  7. 「史诗级干货」新人up主B站运营炫酷玩法,轻松实现UP!UP!UP!
  8. VVC中的熵编码-JVET提案Q2002
  9. mathmatic engineer
  10. 三星s6经常信号无服务器,看看你中招了没?盘点三星S6 Edge六大常见问题