Documentation v1.0.11

Preview Purchase

Overview

ChartJSis a simple yet flexible JavaScript charting for designers & developers. For more info please visit the plugin's Homeor 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 divwith a unique idin your HTML markup. Then initialize the chart via javascript.
var ctx = document.getElementById('kt_chartjs_1');

// Define colors
var primaryColor = KTUtil.getCssVariableValue('--bs-primary');
var dangerColor = KTUtil.getCssVariableValue('--bs-danger');
var successColor = KTUtil.getCssVariableValue('--bs-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 divwith a unique idin your HTML markup. Then initialize the chart via javascript.
var ctx = document.getElementById('kt_chartjs_2');

// Define colors
var primaryColor = KTUtil.getCssVariableValue('--bs-primary');
var dangerColor = KTUtil.getCssVariableValue('--bs-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 divwith a unique idin your HTML markup. Then initialize the chart via javascript.
var ctx = document.getElementById('kt_chartjs_3');

// Define colors
var primaryColor = KTUtil.getCssVariableValue('--bs-primary');
var dangerColor = KTUtil.getCssVariableValue('--bs-danger');
var successColor = KTUtil.getCssVariableValue('--bs-success');
var warningColor = KTUtil.getCssVariableValue('--bs-warning');
var infoColor = KTUtil.getCssVariableValue('--bs-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 divwith a unique idin your HTML markup. Then initialize the chart via javascript.
var ctx = document.getElementById('kt_chartjs_4');

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

// 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 divwith a unique idin your HTML markup. Then initialize the chart via javascript.
var ctx = document.getElementById('kt_chartjs_5');

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

// Define fonts
var fontFamily = KTUtil.getCssVariableValue('--bs-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>
Learn & Get Inspired

Support at devs.keenthemes.com

Join our developers community to find answer to your question and help others. FAQs
Get Support
Documentation
From guides and how-tos, to live demos and code examples to get started right away.
Plugins & Components
Check out our 300+ in-house components and customized 3rd-party plugins.
Layout Builder
Build your layout, preview it and export the HTML for server side integration.
What's New
Latest features and improvements added with our users feedback in mind.
Buy now