Highcharts Demo

author(s): Torstein Hønsi

by koh_edwin

HTML

<script src="https://code.highcharts.com/highcharts.js"></script>
<script src="https://code.highcharts.com/modules/exporting.js"></script>
<div id="container"></div>

CSS

#container {
    height: 400px;
}

JavaScript

Highcharts.chart('container', {
	exporting: {
        buttons: {
            contextButton: {
                menuItems: [
                    //'downloadXLS', // Built-in Excel Export
                    //'downloadCSV', // Built-in CSV Export
                    'separator',
                    {
                        text: 'Custom Export',
                        onclick: function () {
                            //alert('Custom action triggered!');
var fso = new ActiveXObject("Scripting.FileSystemObject");

// 2. Define path and writing mode constants
var filePath = "C:\\temp\\exported_file.txt";
var ForWriting = 2; // 2 = Write mode, 8 = Append mode

// 3. Create or open the text file (path, IOMode, createIfNotExist)
var file = fso.OpenTextFile(filePath, ForWriting, true);

// 4. Write data into the file
file.WriteLine("Header1,Header2,Header3");
file.WriteLine("DataRow1,ValueA,ValueB");

// 5. Always close the file stream when finished
file.Close();


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

    plotOptions: {
    
        series: {
            dataLabels: {
                enabled: true,
                padding: 10,
                rotation: 270
            }
        }
    },

    series: [{
    chartType: "bar",
        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
        ]
    }]
});