简体   繁体   English

Adobe Edge Animate和d3.js:d3.scale.range([value])在Chrome和Safari中无法正常工作

[英]Adobe Edge Animate and d3.js: d3.scale.range([value]) not working properly in Chrome and Safari

I'm trying to create a bar chart using Adobe Edge Animate and d3.js. 我正在尝试使用Adobe Edge Animate和d3.js创建条形图。

I'm having some difficulties with how the different browsers displays the axes. 我在使用不同的浏览器显示坐标轴时遇到一些困难。 Here is a link to a d3 chart only containing axes and no data (the code is in d3example2_edgeActions.js ): 这是到仅包含轴且没有数据的d3图表的链接(代码在d3example2_edgeActions.js中 ):

http://www.nyhetsgrafikk.no/demo/d3example2/d3example2.html http://www.nyhetsgrafikk.no/demo/d3example2/d3example2.html

  • Mozilla Firefox and Opera: everything works Mozilla Firefox和Opera:一切正常
  • Chrome and Safari: ticks are stacked on top of each other to the left Chrome和Safari:刻度线彼此堆叠在左侧

I believe this has to do with d3.scale.range([value]) not working properly - all though it does set the range of the chart (when I change the range and run the code my chart is changed), the ticks are stacked on top of each other. 我相信这与d3.scale.range([value])不能正常工作有关-尽管它确实设置了图表的范围(当我更改范围并运行更改图表的代码时),刻度是彼此堆叠。 Chrome is not returning any errors. Chrome没有返回任何错误。 Any ideas to how I can fix this? 关于如何解决此问题的任何想法?

Turns out the range wasn't the problem. 事实证明范围不是问题。 By adding a webkit-transform to my ticks and axis text everything now works fine 通过在我的刻度和轴文本中添加一个webkit-transform,现在一切正常

.style("-webkit-transform", function(d){ return "translate(" + 0 + "px," + y(d) + "px)"; });

Adding a webkit-transform also does the trick if you're trying to create a d3 pie chart with edge animate, and probably in all other cases where you're using transform in d3. 如果要创建带有边缘动画的d3饼图,以及在所有其他情况下都在d3中使用transform的情况下,添加webkit-transform也可以解决问题。 You might also want to add a ms-transform: http://www.w3schools.com/css/css3_2dtransforms.asp 您可能还想添加一个ms-transform: http : //www.w3schools.com/css/css3_2dtransforms.asp

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

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