Hi please guide me how can connect this chart to my Gsheet
{
type: ‘bar’,
data: {
labels: [
‘January’,
‘February’,
‘March’,
‘April’,
‘May’,
‘June’,
‘July’,
‘August’,
‘September’,
‘October’,
‘November’,
‘December’,
],
datasets: [
{
label: ‘Triangles’,
data: [
{ x: ‘January’, y: 30, label: ‘10%’ },
{ x: ‘February’, y: 21, label: ‘11%’ },
{ x: ‘March’, y: 22, label: ‘12%’ },
{ x: ‘April’, y: 43, label: ‘13%’ },
{ x: ‘May’, y: 24, label: ‘-14%’ },
{ x: ‘June’, y: 25, label: ‘15%’ },
{ x: ‘July’, y: 26, label: ‘-16%’ },
{ x: ‘August’, y: 27, label: ‘17%’ },
{ x: ‘September’, y: 28, label: ‘-18%’ },
{ x: ‘October’, y: 29, label: ‘19%’ },
{ x: ‘November’, y: 30, label: ‘-20%’ },
{ x: ‘December’, y: 31, label: ‘21%’ },
],
type: ‘line’,
fill: false,
borderColor: ‘transparent’,
borderWidth: 0,
pointStyle: ‘triangle’,
pointRadius: 8,
pointBackgroundColor: function (context) {
return context.raw.label[0] === ‘-’ ? ‘#01b050’ : ‘#ff0101’;
},
pointRotation: function (context) {
return context.raw.label[0] === ‘-’ ? 180 : 0;
},
},
{
label: ‘Bars’,
data: [20, 11, 12, 33, 14, 15, 16, 17, 18, 19, 20, 21],
backgroundColor: [
‘#01b050’,
‘#ffc000’,
‘#ff0101’,
‘#01b050’,
‘#ffc000’,
‘#ff0101’,
‘#01b050’,
‘#ffc000’,
‘#ff0101’,
‘#01b050’,
‘#ffc000’,
‘#ff0101’,
],
borderColor: ‘transparent’,
borderWidth: 1,
},
{
label: ‘Line’,
data: [30, 31, 32, 33, 34, 35, 36, 39, 40, 41, 42, 43],
type: ‘line’,
fill: ‘origin’,
backgroundColor: ‘#e9f6dc’,
borderColor: ‘#ccc’,
borderWidth: 1,
borderDash: [5, 5],
pointRadius: 0,
xAxisID: ‘x1’,
},
],
},
options: {
scales: {
x: {
grid: {
display: false,
},
ticks: {
maxRotation: 90,
minRotation: 90,
},
},
x1: {
display: false,
offset: false,
},
y: {
min: 0,
max: 100,
grid: {
borderDash: [5, 5],
},
ticks: {
stepSize: 20,
callback: function (value) {
return value + ‘%’;
},
font: {
weight: ‘bold’,
},
},
},
},
plugins: {
legend: {
display: false,
},
datalabels: {
display: function (context) {
return context.datasetIndex === 0 || context.datasetIndex === 1;
},
formatter: function (value, context) {
return context.datasetIndex === 0 ? value.label : value + ‘%’;
},
anchor: function (context) {
return context.datasetIndex === 0 ? ‘end’ : ‘center’;
},
align: function (context) {
return context.datasetIndex === 0 ? ‘end’ : ‘center’;
},
color: function (context) {
if (context.datasetIndex === 1) {
// White text for bars with green background.
return context.dataset.backgroundColor[context.dataIndex] ===
‘#01b050’
? ‘#fff’
: ‘#000’;
}
},
offset: -4,
},
},
},
}
