简体   繁体   English

react-native&d3选择库

[英]react-native & d3 selection library

Currently working on a react-native app with live data streaming from a Bluetooth library. 目前正在使用来自蓝牙库的实时数据流的反应原生应用程序。 Therefore i need a chart that is constantly rendering itself like the example here (if anyone can suggest a similar library that would be great), but the code is written is html & javascript. 因此,我需要一个不断渲染自己的图表,就像这里的例子一样(如果有人可以建议一个类似的库,那将是很棒的),但代码编写的是html和javascript。 and because there are conflicts between React & d3 in this case d3.selection library. 并且因为在这种情况下React和d3之间存在冲突d3selection库。 i try to work my way around it according to this article . 根据这篇文章,我试着绕着它努力。 i try to convert it into react native code but the selection library does not work, and i couldn't find any example using d3.selection in react native. 我尝试将其转换为反应本机代码,但选择库不起作用,我找不到任何使用反应原生d3.selection的例子。 I'm wondering if d3-selection supports react native. 我想知道d3选择是否支持本机反应。 and this is the error i got is this.querySelectorAll is not a function, appreciate if anyone can help me out, here is the code i need working. 这是我得到的错误是this.querySelectorAll不是一个函数,感谢任何人可以帮助我,这是我需要工作的代码。

select(node)
  .selectAll("rect")
  .data(this.props.data)
  .style("fill", "#fe9922")
  .attr("x", (d, i) => i * 25)
  .attr("y", d => this.props.size[1] - yScale(d))
  .attr("height", d => yScale(d))
  .attr("width", 25);

There are two ways to make d3 work with react-native. 有两种方法可以使d3与react-native一起工作。 one is with react-native ART and other one is with SVG using react-native-svg. 一个是反应原生ART,另一个是SVG使用react-native-svg。 For some 3D graph, react-native-svg works better. 对于某些3D图形,react-native-svg效果更好。 You use refs attribute in a d3 selection to refer to svg. 您在d3选择中使用refs属性来引用svg。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM