JSFiddle - React, Tailwind, and code Playground
by Osvaldo
HTML
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/Chart.bundle.min.js" defer></script>
<script src="https://cdn.jsdelivr.net/npm/[email protected]" defer></script>
<div class="chart-container" style="position: relative; height:auto; width:100%">
<canvas id="line_chart_1x" width="350" height="250"></canvas>
</div>
<script>
document.addEventListener("DOMContentLoaded", function(event) {
var ctx = document.getElementById("line_chart_1x");
var line_chart_1 = new Chart(ctx, {
type: 'line',
data: {
labels: ["2012", "2013", "2014", "2015", "2016", "2017"],
datasets: [{
label: 'Renault',
data: [12, 19, 3, 5, 2, 3],
borderColor: 'rgba(142, 229, 187, 1)',
backgroundColor: 'rgba(0,0,0,0)'
},
{
label: 'Toyota',
data: [11, 19, 4, 9, 5, 10],
borderColor: 'rgba(255, 160, 0, 1)',
backgroundColor: 'rgba(0,0,0,0)'
},
{
label: 'Mercedez',
data: [10, 20, 8, 9, 9, 8],
borderColor: 'rgba(91, 74, 89, 1)',
backgroundColor: 'rgba(0,0,0,0)'
}
]
},
options: {
title: {
display: true,
text: 'Comparación de datos en el tiempo',
fontSize: 16,
fontFamily: '"Work Sans",sans-serif',
fontColor: '#212529'
},
legend: {
display: true,
labels: {
fontName: '"Work Sans",sans-serif',
fontColor: '#212529',
fontSize: 13
...