jQuery   发布时间:2022-03-30  发布网站:大佬教程  code.js-code.com
大佬教程收集整理的这篇文章主要介绍了jquery – 将D3.js CSS样式转换为内联样式大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
我有两种类型的图表,我试图导出.我正在使用SVG Crowbar,它在Chrome中运行良好,但在Firefox中它不会导出CSS(我只是不打扰IE).我决定将所有CSS转换为内联样式.但是,我遇到了2个问题(每个图表有1个问题).

在条形图中,我似乎无法应用“笔画:黑色”;仅限轴,而不是轴标签. “笔画:黑色”使标签模糊,没有吸引力.这是问题的JSfiddlehttp://jsfiddle.net/UK8bw/10/.这是轴/标签代码.我试图将它们分开,没有成功.我在CSS部分留下了相关的CSS注释.

svg.append("g")
    .attr("class","xAxis")
    .attr("fill","none")
    .attr("stroke","black")
    .style("shape-rendering","crispEdges")
    .attr("transform","translate(0," + height + ")")
    .call(xAxis)
    .SELEctAll("text")
    .style("text-anchor","end")
    .attr("dx","-.6em")
    .attr("dy","-0.195em")
    .attr("transform",function (d) {
        return "rotate(-90)"
    });  

svg.append("g")
    .attr("class","yAxis")
    .attr("fill","black")
    .attr("shape-rendering","crispEdges")
    .call(yAxis)
    .append("text")
    .attr("transform","rotate(-90)")
    .attr("y",6)
    .attr("dy",".71em")
    .style("text-anchor","end")
    .text("Y-Axis Label");

我也有一个饼图.我设法将所有CSS样式转换为内联样式,但是我遇到了一个新问题.图例和图表本身显示在两个不同的SVG上.因此,我不能将它们都下载到一个文件中.有没有办法在同一个SVG上显示图表和图例?这是一个JSfiddlehttp://jsfiddle.net/NYEaX/7/

解决方法

最简单的方法是设置你想要的样式,即

svg.append("g")
  .attr("class","xAxis")
  .attr("fill","none")
  .attr("stroke","black")
  .style("shape-rendering","crispEdges")
  .attr("transform"," + height + ")")
  .call(xAxis)
  .SELEctAll("text")
  .style("fill","black")
  .style("stroke","none")
  .style("text-anchor","end")
  .attr("dx","-.6em")
  .attr("dy","-0.195em")
  .attr("transform",function (d) {
    return "rotate(-90)"
  });

更新了jsfiddle here.

大佬总结

以上是大佬教程为你收集整理的jquery – 将D3.js CSS样式转换为内联样式全部内容,希望文章能够帮你解决jquery – 将D3.js CSS样式转换为内联样式所遇到的程序开发问题。

如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。