Highcharts test tool

by Kesav Telaprolu

HTML

<script src="https://code.highcharts.com/highcharts.js"></script>
<script src="https://code.highcharts.com/modules/exporting.js"></script>
<script src="https://cdn.jsdelivr.net/canvg/1.4.0/rgbcolor.js"></script>

<div id="container"></div>

CSS

#container {
    min-width: 300px;
    max-width: 800px;
    height: 300px;
    margin: 1em auto;
}

JavaScript

Highcharts.Color.prototype.parsers.push({
	regex: /^[a-z]+$/,
    parse: function (result) {
    	var rgb = new RGBColor(result[0]);
        if (rgb.ok) {
        	return [rgb.r, rgb.g, rgb.b, 1]; // returns rgba to Highcharts
        }
    }
});

Highcharts.chart('container', {

	title: {
    	text: 'Named colors'
    },

	colors: ['red', 'orange', 'green', 'blue', 'purple', 'brown'],

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

    series: [{
        data: [4, 3, 5, 4, 6, 1],
        type: 'column',
        colorByPoint: true
    }]

});