Language : JavaScript
I want to include some patterns in my bars of bar chart. I dont see anything available in plotly by default to serve the purpose .
So I tried getting hold of the "point" element in the dynamically generated "svg" component.And then create a "pattern" element. I thought after creating the inner pattern tag , i will able to set cusotom attributes.
But its not working at all.
Below is the code sample used :
var data = [{
x: ['giraffes', 'orangutans', 'monkeys'],
y: [20, 14, 23],
type: 'bar'
}];
Plotly.newPlot('myDiv',data);
var ticks = document.getElementsByClassName('point');
for (var i = 0; i < ticks.length; i += 1) {
var patt = document.createElement("pattern");
patt.setAttribute('patternTransform','rotate(30)');
patt.setAttribute('patternUnits','userSpaceOnUse');
patt.setAttribute('fill', 'red');
ticks[i].appendChild(patt);
}
And I am taking reference of the below "" tag which I found online somewhere..
<pattern id="diagonal-stripes-4-8" x="0" y="0" width="8" height="8" patternUnits="userSpaceOnUse" patternTransform="rotate(30)">
<rect x="0" y="0" width="4" height="8" style="stroke:none; fill:purple;" />
</pattern>