JSFiddle - React, Tailwind, and code Playground

by hfrntt

HTML

<script type="text/javascript" src="http://highcharts.com/js/testing.js"></script>

<div id="container" style="height: 300px"></div>

<button id="title">Set title</button>
<button id="subtitle">Set subtitle</button>
<button id="color">New color</button>

JavaScript

window.chart = new Highcharts.Chart({

    chart: {
        renderTo: 'container'
    },
    
    subtitle: {
        text: 'Subtitle'
    },

    xAxis: {
        categories: ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec']
    },

    series: [{
        data: [29.9, 71.5, 106.4, 129.2, 144.0, 176.0, 135.6, 148.5, 216.4, 194.1, 95.6, 54.4]
    }]

});

var i = 1;
$('#title').click(function() {
    chart.setTitle({ text: 'New title '+ i++ });
});
$('#subtitle').click(function() {
    chart.setTitle(null, { text: 'New title '+ i++ });
});
$('#color').click(function() {
    chart.setTitle(
        { style: { color: 'red' }},
        { style: { color: 'green' }}
    );
});