# JSChart Custom Component

> For more options on custom charts, here is a walkthrough on how you can complete this JSChart.

Source: https://tadabase.com/docs/snippets/jschart-custom-component  
Status: Not yet re-checked. Moved from our previous help site and not yet re-checked against the current product. Last edited Sep 20, 2024.

![Screenshot for “JSChart Custom Component”](https://community.tadabase.io/uploads/default/optimized/2X/7/78e8a6c700181e8e37611da4f143e798e1ff0b73_2_690x410.png)

For more options on custom charts, here is a walkthrough on how you can complete this JSChart.

**Step 1**

**Add the ChartJS CDN code to the header of your app.**

```
<script src="https://cdnjs.cloudflare.com/ajax/libs/Chart.js/3.7.0/chart.min.js" integrity="sha512-TW5s0IT/IppJtu76UbysrBH9Hy/5X41OTAbQuffZFU6lQ1rdcLHzpU5BzVvr/YFykoiMYZVWlr/PX1mDcfM9Qg==" crossorigin="anonymous" referrerpolicy="no-referrer"></script>
```

![Screenshot for “JSChart Custom Component”](https://tadabase-docs-assets.s3.amazonaws.com/uploads/images/gallery/2022-10/scaled-1680-/image-1664757436364.png)

**Step 2**

**Add a Custom Component. Add the following settings in calculations in the Data Source of the component.**

![Screenshot for “JSChart Custom Component”](https://tadabase-docs-assets.s3.amazonaws.com/uploads/images/gallery/2022-10/scaled-1680-/image-1664757988120.png)

**Step 3**

**In your custom component template tab, add the following code.**

```
{{#each records}}
    <div class="hide">
        <h1><div id="totalRecords">{{total}}</div></h1>
        <h1><div id="maxRecords">{{max}}</div></h1>
        <h1><div id="minRecords">{{min}}</div></h1>
    </div>
{{/each}}

<div>
  <canvas id="myChart"></canvas>
</div>
```

![Screenshot for “JSChart Custom Component”](https://tadabase-docs-assets.s3.amazonaws.com/uploads/images/gallery/2022-10/scaled-1680-/image-1664758308739.png)

**Step 4**

**Add the following code to the JavaScript tab within your custom component.**

```
$(document).ready(function() {
    var total = $("#totalRecords").html();
    var max = $("#maxRecords").html();
    var min = $("#minRecords").html();

    new Chart(document.getElementById("myChart"), {
        type: 'bar',
        data: {
            labels: ["Total", "Max", "Min"],
            datasets: [{
                label: "Totals",
                backgroundColor: ["#3e95cd", "#8e5ea2", "#3cba9f"],
                data: [total, max, min]
            }]
        }
    });

});
```

![Screenshot for “JSChart Custom Component”](https://tadabase-docs-assets.s3.amazonaws.com/uploads/images/gallery/2022-10/scaled-1680-/image-1664758463325.png)

**Original Community Post:**

[Add record values on the javascript tab of a custom component - Community Discussions / How Do I - Tadabase Community](https://community.tadabase.io/t/add-record-values-on-the-javascript-tab-of-a-custom-component/1766/4)
