Documentation v8.2.7

Downloads Preview

Overview

ChartJS is a simple yet flexible JavaScript charting for designers & developers. For more info please visit the plugin's Home or Github Repo.

Usage

ChartJS's CSS and Javascript files are bundled in the global style and scripts bundles and are globally included in all pages:
<link href="assets/plugins/global/plugins.bundle.css" rel="stylesheet" type="text/css"/>
<script src="assets/plugins/global/plugins.bundle.js"></script>

Bar Chart

Simply define a blank div with a unique id in your HTML markup. Then initialize the chart via javascript.
var ctx = document.getElementById('kt_chartjs_1');

// Define colors
var primaryColor = KTUtil.getCssVariableValue('--kt-primary');
var dangerColor = KTUtil.getCssVariableValue('--kt-danger');
var successColor = KTUtil.getCssVariableValue('--kt-success');

// Define fonts
var fontFamily = KTUtil.getCssVariableValue('--bs-font-sans-serif');

// Chart labels
const labels = ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'];

// Chart data
const data = {
    labels: labels,
    datasets: [
        ...
    ]
};

// Chart config
const config = {
    type: 'bar',
    data: data,
    options: {
        plugins: {
            title: {
                display: false,
            }
        },
        responsive: true,
        interaction: {
            intersect: false,
        },
        scales: {
            x: {
                stacked: true,
            },
            y: {
                stacked: true
            }
        }
    },
    defaults:{
        global: {
            defaultFont: fontFamily
        }
    }
};

// Init ChartJS -- for more info, please visit: https://www.chartjs.org/docs/latest/
var myChart = new Chart(ctx, config);
<canvas id="kt_chartjs_1" class="mh-400px"></canvas>

Line Chart

Simply define a blank div with a unique id in your HTML markup. Then initialize the chart via javascript.
var ctx = document.getElementById('kt_chartjs_2');

// Define colors
var primaryColor = KTUtil.getCssVariableValue('--kt-primary');
var dangerColor = KTUtil.getCssVariableValue('--kt-danger');

// Define fonts
var fontFamily = KTUtil.getCssVariableValue('--bs-font-sans-serif');

// Chart labels
const labels = ['January', 'February', 'March', 'April', 'May', 'June', 'July'];

// Chart data
const data = {
    labels: labels,
    datasets: [
        ...
    ]
};

// Chart config
const config = {
    type: 'bar',
    data: data,
    options: {
        plugins: {
            title: {
                display: false,
            }
        },
        responsive: true,
    },
    defaults:{
        global: {
            defaultFont: fontFamily
        }
    }
};

// Init ChartJS -- for more info, please visit: https://www.chartjs.org/docs/latest/
var myChart = new Chart(ctx, config);
<canvas id="kt_chartjs_2" class="mh-400px"></canvas>

Pie Chart

Simply define a blank div with a unique id in your HTML markup. Then initialize the chart via javascript.
var ctx = document.getElementById('kt_chartjs_3');

// Define colors
var primaryColor = KTUtil.getCssVariableValue('--kt-primary');
var dangerColor = KTUtil.getCssVariableValue('--kt-danger');
var successColor = KTUtil.getCssVariableValue('--kt-success');
var warningColor = KTUtil.getCssVariableValue('--kt-warning');
var infoColor = KTUtil.getCssVariableValue('--kt-info');

// Define fonts
var fontFamily = KTUtil.getCssVariableValue('--bs-font-sans-serif');

// Chart labels
const labels = ['January', 'February', 'March', 'April', 'May'];

// Chart data
const data = {
    labels: labels,
    datasets: [
        ...
    ]
};

// Chart config
const config = {
    type: 'pie',
    data: data,
    options: {
        plugins: {
            title: {
                display: false,
            }
        },
        responsive: true,
    },
    defaults:{
        global: {
            defaultFont: fontFamily
        }
    }
};

// Init ChartJS -- for more info, please visit: https://www.chartjs.org/docs/latest/
var myChart = new Chart(ctx, config);
<canvas id="kt_chartjs_3" class="mh-400px"></canvas>

Stacked Bar & Line Chart

Simply define a blank div with a unique id in your HTML markup. Then initialize the chart via javascript.
var ctx = document.getElementById('kt_chartjs_4');

// Define colors
var primaryColor = KTUtil.getCssVariableValue('--kt-primary');
var dangerColor = KTUtil.getCssVariableValue('--kt-danger');
var dangerLightColor = KTUtil.getCssVariableValue('--kt-danger-light');

// Define fonts
var fontFamily = KTUtil.getCssVariableValue('--bs-font-sans-serif');

// Chart labels
const labels = ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'];

// Chart data
const data = {
    labels: labels,
    datasets: [
        ...
    ]
};

// Chart config
const config = {
    type: 'line',
    data: data,
    options: {
        plugins: {
            title: {
                display: false,
            },
            legend: {
                labels: {
                    // This more specific font property overrides the global property
                    font: {
                        size: 15,
                        family: fontFamily
                    }
                }
            }
        },
        responsive: true,
        interaction: {
            intersect: false,
        },
        scales: {
            y: {
                stacked: true
            }
        }
    },
    defaults:{
        global: {
            defaultFont: fontFamily
        }
    }
};

// Init ChartJS -- for more info, please visit: https://www.chartjs.org/docs/latest/
var myChart = new Chart(ctx, config);
<canvas id="kt_chartjs_4" class="mh-400px"></canvas>

Radar Chart

Simply define a blank div with a unique id in your HTML markup. Then initialize the chart via javascript.
var ctx = document.getElementById('kt_chartjs_5');

// Define colors
var infoColor = KTUtil.getCssVariableValue('--kt-info');
var infoLightColor = KTUtil.getCssVariableValue('--kt-info-light');
var warningColor = KTUtil.getCssVariableValue('--kt-warning');
var warningLightColor = KTUtil.getCssVariableValue('--kt-warning-light');
var primaryColor = KTUtil.getCssVariableValue('--kt-primary');
var primaryLightColor = KTUtil.getCssVariableValue('--kt-primary-light');

// Define fonts
var fontFamily = KTUtil.getCssVariableValue('--md-font-sans-serif');

// Chart labels
const labels = ['January', 'February', 'March', 'April', 'May', 'June'];

// Chart data
const data = {
    labels: labels,
    datasets: [
        ...
    ]
};

// Chart config
const config = {
    type: 'pie',
    data: data,
    options: {
        plugins: {
            title: {
                display: false,
            },
            legend: {
                labels: {
                    // This more specific font property overrides the global property
                    font: {
                        size: 15,
                        family: fontFamily
                    }
                }
            }
        },
        responsive: true,
    },
    defaults:{
        global: {
            defaultFont: fontFamily
        }
    }
};

// Init ChartJS -- for more info, please visit: https://www.chartjs.org/docs/latest/
var myChart = new Chart(ctx, config);
<canvas id="kt_chartjs_5" class="mh-400px"></canvas>
Preview Get Help Buy Now