gpt4 book ai didi

svg - 如何访问 G. Raphael 折线图中的单个线条并为其设置样式

转载 作者:行者123 更新时间:2023-12-04 19:58:30 25 4
gpt4 key购买 nike

由于 raphael JS 库的文档很差,我恳求集体智慧。

我有一个工作 g。 raphael 多线折线图(类似于 http://g.raphaeljs.com/linechart.html)

就像是:
var lineChart = rglinechart(10,10,300,220,[1,2,3,4,5],[[10,20,15,35,30],[5,10,5,15,20]], {shade :true, "colors":["#44F","#CCC"], nostroke:true});

我想更改其中一行以设置填充 = 清除和描边 = 颜色

有人告诉我这样的事情会起作用,但没有运气 - 有什么建议吗?
lineChart.lines[0].attr({stroke: "#000"}),

额外的功劳,如何将线条的填充设置为渐变?

谢谢!

最佳答案

我使用 Firebug 和 console.log() 在一行上列出属性:

console.log(chart.lines[0].attr());

我点击日志行查看详细信息,如下所示:
fill: "none"
path: [ ... ]
stroke: "#ff0000"
stroke-dasharray: ""
stroke-linecap: "round"
stroke-linejoin: "round"
stroke-width: 2
transform: []

对我来说,我想改变笔画宽度。此代码有效:
chart.lines[0].attr({'stroke-width': 8});
line-width属性在 the excellent RaphaelJS documentation 中列出.

对于您的问题,我希望您需要这样的代码:
chart.lines[0].attr({'fill': 'none', 'stroke': '#FF00FF'});

我希望这有帮助!

关于svg - 如何访问 G. Raphael 折线图中的单个线条并为其设置样式,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4610122/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com