ColumnChart

Table of contents
No headers
var width = $width;
var height = $height;
var min = $min;
var title = $title;
var type = $type;
var data = $data;
var xaxis = $xaxis;
var yaxis = $yaxis;

<html>
    <head>
        <script type="text/javascript" src="https://www.google.com/jsapi"></script>
        <script type="text/javascript">
            "google.load('visualization', '1.0', { 'packages':['corechart'] });"
        </script>
    </head>
</html>

if(xaxis is xml) {
    let xaxis = xml.text(xaxis);
}
if(yaxis is xml) {
    let yaxis = xml.text(yaxis);
}
if(title is xml) {
    let title = xml.text(title);
}

<div id=(@chart) style=("width: " .. width .. "px; height:" .. height .. "px;") />

if(data is list) {
    let data = { "Series": data };
} else if(data is not map) {

    // problem
    "Invalid chart type";
    return;
}

var series = map.keys(data)[0];

var table = {
    cols: [ { label: 'Age', type: 'string' }, { label: series, type: 'number' } ],
    rows: [
        {
            c: [
                {
                    v: label
                }, {
                    v: value
                }
            ]
        }
        foreach var values in data[series], var label = map.keys(values)[0], var value = values[label]
    ]
};
google.setOnLoadCallback(function() {
    var data = new google.visualization.DataTable({{ table }});
    var chart = new google.visualization.ColumnChart(document.getElementById({{ @chart }}));
    options = {
        chartArea: {
            width: 400, 
            left: 80
        },
        width: {{width}},
        height: {{height}},
        hAxis: {
            title: {{xaxis}},
            slantedText: false
        },
        vAxis:{
            title: {{yaxis}}, 
            showTextEvery: 2,
            maxValue: 10
        },
        colors:['#912B1D','#CC422F'],
        backgroundColor: {
            fill: 'white',
            stroke: '#999',
            strokeWidth: 2
        },
        legend: 'none'
    };
    chart.draw(data, options);
});
Page statistics
70 view(s), 3 edit(s) and 2193 character(s)

Tags

This page has no custom tags set.

Comments

You must to post a comment.

Attach file

Attachments