I am working on a time series chart and wondering if it’s possible for a chart to have like a gradient background. This is the pen of what I currently have: https://codepen.io/boinx-fm/pen/RqogXV
JavaScript
x
8
1
var data = [{
2
x: [time],
3
y: [rand()],
4
mode:'lines',
5
fill:'tozeroy',
6
fillcolor :'rgba(249, 180, 14, 0.5)
7
}];
8
Attached is the sample background I’m trying to achieve:
Thanks!
Advertisement
Answer
Plotly.js does not support gradient color at this moment.
You can subscribe to https://github.com/plotly/plotly.js/issues/581 for development info.
To change background color of the layout:
JavaScript
1
17
17
1
var layout = {
2
xaxis:{
3
range:[newTime,nextTime]
4
},
5
yaxis:{
6
range:[0,1],
7
zeroline: false,
8
showline: false,
9
autotick: true,
10
ticks: '',
11
showticklabels: false
12
},
13
// Change background color here ...
14
paper_bgcolor: 'green',
15
plot_bgcolor: 'blue'
16
}
17