</> ConvertAtlas Developer Tools
Bootstrap 5 · Advanced

Switchable Chart Type

One chart that switches between line, bar and area, via ApexCharts.

Requires Bootstrap 5, ApexCharts. Add the CDN tags below to your page (styles in <head>, scripts before </body>). The downloaded file already includes them.
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.min.css">
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/js/bootstrap.bundle.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/apexcharts@3.49.1/dist/apexcharts.min.js"></script>
<div class="card border-0 shadow-sm" style="width:420px;max-width:100%"><div class="card-body">
  <div class="btn-group btn-group-sm mb-2" id="mcTabs"><button class="btn btn-primary" data-t="line">Line</button><button class="btn btn-outline-primary" data-t="bar">Bar</button><button class="btn btn-outline-primary" data-t="area">Area</button></div>
  <div id="mcChart"></div>
</div></div>
var data=[31,40,28,51,42,62],chart=new ApexCharts(document.getElementById('mcChart'),{chart:{type:'line',height:200,toolbar:{show:false}},series:[{name:'Data',data:data}],colors:['#0d6efd'],stroke:{curve:'smooth',width:3},dataLabels:{enabled:false},xaxis:{categories:['Jan','Feb','Mar','Apr','May','Jun']}});
chart.render();
document.querySelectorAll('#mcTabs [data-t]').forEach(function(b){b.onclick=function(){document.querySelectorAll('#mcTabs [data-t]').forEach(function(x){x.className='btn btn-outline-primary'});b.className='btn btn-primary';chart.updateOptions({chart:{type:b.dataset.t}})}});
Free to use.This component uses Bootstrap 5, ApexCharts (linked above). Copy any file, or download a ready-to-open .html page with the CDN links already included.