admin管理员组文章数量:1024603
Following the chart.js docs, I try to draw a transparent stroke line in a pie chart:
var options = { segmentStrokeColor: "rgba(255,255,255,0)" };
or
var options = { segmentStrokeColor: "transparent" };
But the stroke line is not drawn with these values. Of course it works if I use any other color.
Following the chart.js docs, I try to draw a transparent stroke line in a pie chart:
var options = { segmentStrokeColor: "rgba(255,255,255,0)" };
or
var options = { segmentStrokeColor: "transparent" };
But the stroke line is not drawn with these values. Of course it works if I use any other color.
Share Improve this question asked Jun 5, 2015 at 11:01 ManoloManolo 26.6k21 gold badges89 silver badges134 bronze badges 4- Can you use your own class names in chart.js? – lharby Commented Jun 5, 2015 at 11:04
-
@lharby - Do you mean to use an other name for
options
object? – Manolo Commented Jun 5, 2015 at 11:07 - I was thinking if you can apply your own class name to the element you want, you can then write svg css, see here: developer.mozilla/en-US/docs/Web/SVG/Attribute/…. Set stroke opacity to 0. But this might not be supported as part of the chart.js options. – lharby Commented Jun 5, 2015 at 11:09
- Why not make a jsfiddle? And we can try it out. – lharby Commented Jun 5, 2015 at 11:09
1 Answer
Reset to default 3The border or segment stroke is drawn over the sectors. So if you set the color to transparent, you won't see any gap between the sectors (I assume that is what you are expecting). It'll be almost as if you set storkewidth to 0.
It's pretty obvious if you set the segmentStrokeWidth to a high enough value and set a translucent value i.e. something like
var myPieChart = new Chart(ctx).Pie(data, {
segmentStrokeWidth: 20,
segmentStrokeColor: "rgba(255, 255, 255, 0.4)"
});
Contrast this fiddle - http://jsfiddle/tabb8gy0/ with this - http://jsfiddle/m2k62fgp/
Following the chart.js docs, I try to draw a transparent stroke line in a pie chart:
var options = { segmentStrokeColor: "rgba(255,255,255,0)" };
or
var options = { segmentStrokeColor: "transparent" };
But the stroke line is not drawn with these values. Of course it works if I use any other color.
Following the chart.js docs, I try to draw a transparent stroke line in a pie chart:
var options = { segmentStrokeColor: "rgba(255,255,255,0)" };
or
var options = { segmentStrokeColor: "transparent" };
But the stroke line is not drawn with these values. Of course it works if I use any other color.
Share Improve this question asked Jun 5, 2015 at 11:01 ManoloManolo 26.6k21 gold badges89 silver badges134 bronze badges 4- Can you use your own class names in chart.js? – lharby Commented Jun 5, 2015 at 11:04
-
@lharby - Do you mean to use an other name for
options
object? – Manolo Commented Jun 5, 2015 at 11:07 - I was thinking if you can apply your own class name to the element you want, you can then write svg css, see here: developer.mozilla/en-US/docs/Web/SVG/Attribute/…. Set stroke opacity to 0. But this might not be supported as part of the chart.js options. – lharby Commented Jun 5, 2015 at 11:09
- Why not make a jsfiddle? And we can try it out. – lharby Commented Jun 5, 2015 at 11:09
1 Answer
Reset to default 3The border or segment stroke is drawn over the sectors. So if you set the color to transparent, you won't see any gap between the sectors (I assume that is what you are expecting). It'll be almost as if you set storkewidth to 0.
It's pretty obvious if you set the segmentStrokeWidth to a high enough value and set a translucent value i.e. something like
var myPieChart = new Chart(ctx).Pie(data, {
segmentStrokeWidth: 20,
segmentStrokeColor: "rgba(255, 255, 255, 0.4)"
});
Contrast this fiddle - http://jsfiddle/tabb8gy0/ with this - http://jsfiddle/m2k62fgp/
本文标签: javascriptUse transparent stroke color with chartjs pie chartStack Overflow
版权声明:本文标题:javascript - Use transparent stroke color with chartjs pie chart - Stack Overflow 内容由热心网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://it.en369.cn/questions/1745540436a2155157.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论