RE: How to remove grids from charts.js library?

I am using chart.js file to show graph in my suitelet. Its showing vertical and horizontal grids from graph. Below is code:

 

// Create a chart using Chart.js
        var chartScript = ‘<script type=”text/javascript” src=”https://cdnjs.cloudflare.com/ajax/libs/Chart.js/3.7.0/chart.min.js”></script>’;
        var chartCanvas = ‘<canvas id=”myChart” width=”5″ height=”292″></canvas>’;
        var chartScriptCode = ‘<script>’ +
    ‘var ctx = document.getElementById(“myChart”).getContext(“2d”);’ +
    ‘var myChart = new Chart(ctx, {‘ +
    ‘type: “bar”,’ +
    ‘data: {‘ +
    ‘labels: [“Gross Burn”, “Net Burn”, “EBITDA”],’ +
    ‘datasets: [{‘ +
    ‘label: “KPI Chart”,’ +
    ‘data: [‘ + grossBurn + ‘, ‘ + netBurn + ‘, ‘ + ebidta + ‘],’ +
    ‘backgroundColor: [“rgba(255, 99, 132, 0.2)”, “rgba(54, 162, 235, 0.2)”, “rgba(255, 206, 86, 0.2)”],’ +
    ‘borderColor: [“rgba(255, 99, 132, 1)”, “rgba(54, 162, 235, 1)”, “rgba(255, 206, 86, 1)”],’ +
    ‘borderWidth: 1,’ +
    ‘barThickness: 80’ + // You can adjust the bar width by changing this value
    ‘}]’ +
    ‘},’ +
    ‘options: {‘ +
    ‘responsive: true,’ +
    ‘maintainAspectRatio: false,’ +
    ‘legend: {‘ +
    ‘display: true’ +
    ‘},’ +
    ‘scales: {‘ +
    ‘xAxes: [{‘ +
    ‘ticks: {‘ +
    ‘autoSkip: false’ +
    ‘}’ +
    ‘}],’ +
    ‘yAxes: [{‘ +
    ‘ticks: {‘ +
    ‘beginAtZero: true’ +
    ‘}’ +
    ‘}]’ +
    ‘}’ +
    ‘}’ +
    ‘});’ +
    ‘</script>’;
        // Add the chart to the form
        form.addField({
            id: ‘custom_chart_field’,
            label: ‘Custom Chart Field’,
            type: serverWidget.FieldType.INLINEHTML,
        }).defaultValue = chartScript + chartCanvas + chartScriptCode;
Maira S Beginner Asked on December 26, 2023 in SuiteScript.
Add Comment
2 Answers

See the Grid Line configuration options. Will look something like:


options: {

scales: {

x: {

grid: {

display: false

}

},

y: {

grid: {

display: false

}

}

}

}

Beginner Answered on December 26, 2023.

Sorry about the formatting; it doesn’t want to render my indentation.

on December 26, 2023.
Add Comment

Your Answer

By posting your answer, you agree to the privacy policy and terms of service.