So, I want to set x-axis range from January to December. so x_data and y_data are dynamic for example x_data = [ 'Jan', 'Feb] and y_data = [10, 20]. So the graph shows me only two value at x-axis(jan and feb only) but I want all the months at x-axis if the data is not available . I have tried to set the range of xaxis to ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'] but it is not working. (code below)
var trace1 = {
x: x_data,
y: y_data,
type: 'bar',
marker: {
color: '#FEDB41',
}
};
var data = [trace1];
var layout = {
xaxis: {
type : 'category',
categoryorder : "array",
categoryarray : MONTHS,
zeroline: false,
showline: false,
tickfont : {
size : 10,
color : 'white'
},
// type: 'date',
automargin: true,
tickformat: '%d, %b',
range:['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec']
},
"yaxis": {
"visible": false,
"showgrid": false,
"zeroline": false
},
// barmode: 'group',
margin: {
l: 2,
r: 2,
b: 20,
t: 2,
},
paper_bgcolor: 'rgba(0,0,0,0)',
plot_bgcolor: 'rgba(0,0,0,0)',
};
Plotly.newPlot(div_id, data, layout, {displayModeBar: false});