javascript - d3.js 和 dimple.js 两个相同的元素

标签 javascript jquery html d3.js dimple.js

我使用 dimple.js 库创建了一个图表,代码如下:

var myChart = new dimple.chart(svg, data);
var x = myChart.addMeasureAxis("x", "x-measure");
x.tickFormat = "%";
var y = myChart.addMeasureAxis("y", "y-measure");
y.tickFormat = "%";
myChart.addSeries(["Attribute", "Category"], dimple.plot.scatter);
myChart.draw();

我正在尝试使用 d3 选择图表的 x 轴和 y 轴来改变它们,但是 html 元素几乎相同,所以我不知道如何单独选择它们。使用 d3.select('.dimple-axis').attr("id","x-axis");我已经能够将唯一标识符添加到 x 轴(列出的第一个元素),但我无法选择 y 轴。

这是 HTML 代码:

X 轴:<g class="dimple-axis" transform="translate(0, 540)" id="x-axis" style="font-family: sans-serif; font-size: 10px;">...</g>

Y 轴:<g class="dimple-axis" transform="translate(140, 0)" style="font-family: sans-serif; font-size: 10px;">...</g>

关于如何永久性地向 y 轴添加唯一 ID,或以某种方式使用 d3 选择它,有什么想法吗?

谢谢!

最佳答案

我不知道 dimplejs,但在 the examples 上在他们的网站上提供,X 轴和 Y 轴似乎有各自的 CSS 类 dimple-axis-xdimple-axis-x

也许您应该尝试更新您的 dimplejs 版本?

关于javascript - d3.js 和 dimple.js 两个相同的元素,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32462447/

相关文章:

javascript - 在指令中对输入使用 ngModel,保持 ng-* 兼容性

javascript - 在正则表达式中匹配第一组、第二组或两者

javascript - 从 AJAX 成功函数更新图像源

javascript - 当点击任何网站的扩展名时,pinterest 如何设法在其上加载 iframe?

javascript - jQuery.width() 返回百分比宽度而不是像素宽度

javascript - 如何将 html 开/关翻转开关添加到 jquery?

javascript - React - 遍历数组和事件

javascript - Vue JS 中的递归方法

jQuery 如何找到 div 所在的 li?

html - 如何将背景位置分配为 'margin-right: 10px' 之类的东西?