<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport"
content="width=device-width,
initial-scale=1.0">
<title>LTTB Decimation Example</title>
<script src=
"https://ajax.googleapis.com/ajax/libs/jquery/3.6.1/jquery.min.js">
</script>
<script src=
"https://cdnjs.cloudflare.com/ajax/libs/Chart.js/4.1.2/chart.umd.js">
</script>
</head>
<body>
<div>
<h1 style="color:green;">GeeksforGeeks</h1>
<h3>Data Decimation Configuration - LTTB </h3>
<div style="width:80%;">
<canvas id="lttbChart"></canvas>
</div>
</div>
<script>
const geeksData = {
labels: ['Jan', 'Feb', 'Mar',
'Apr', 'May', 'Jun',
'Jul', 'Aug', 'Sep',
'Oct', 'Nov', 'Dec'],
datasets: [{
label: 'Monthly Visitors',
data: [120, 150, 80, 200, 130,
180, 110, 160, 90, 220,
170, 200],
fill: false,
borderColor: 'blue',
tension: 0.4,
}]
};
const ctx = document.getElementById('lttbChart').getContext('2d');
const lttbChart = new Chart(ctx, {
type: 'line',
data: geeksData,
options: {
plugins: {
decimation: {
enabled: true,
algorithm: 'lttb',
}
}
}
});
</script>
</body>
</html>