PageSourceSearch

https://cym.org/wp-content/plugins/inline-google-spreadsheet-viewe…?ver=3e48e4f0b70423c56d22235fd7626f5c

js cym.org collected 2026-10-02 05:30:16 UTC 4,672 bytes, 128 lines download raw bytes

1/**
2 * Inline Google Spreadsheet Viewer's Google Chart API integrations.
3 *
4 * @file Loads and draws Google Chart API visualizations.
5 * @license GPL-3.0
6 * @author Meitar Moscovitz <[email protected]>
7 * @copyright Copyright 2017 by Meitar "maymay" Moscovitz
8 */
9
10(function () { // start immediately-invoked function expresion (IIFE)
11
12google.load('visualization', '1.0', {
13    'packages' : [
14        'corechart',
15        'annotatedtimeline',
16        'annotationchart',
17        'gauge',
18        'geochart',
19        'timeline'
20    ]
21});
22
23jQuery(document).ready(function () {
24    jQuery('.igsv-chart').each(function () {
25        var chart_id = jQuery(this).attr('id'),
26            query = new google.visualization.Query(jQuery(this).data('datasource-href')),
27            options = lowerFirstCharInKeys(stripPrefixInKeys('chart', jQuery(this).data()));
28
29        // Special-case chart options.
30        options.title = jQuery(this).attr('title');
31        delete options.type; // handled elsewhere
32        for (x in options) {
33            switch (x) {
34                case 'colors':
35                    options.colors = jQuery(this).data('chart-colors').split(' ');
36                break;
37                case 'dimensions':
38                    options.is3D = (3) ? true : false;
39                    delete options.dimensions;
40                break;
41            }
42        }
43
44        query.send(function (response) {
45            if (response.isError()) {
46                return; // bail, let Google handle displaying errors
47            }
48            var data = response.getDataTable(),
49                chart_el = document.getElementById(chart_id),
50                chart;
51            switch (jQuery('#' + chart_id).data('chart-type').toLowerCase()) {
52                case 'annotatedtimeline':
53                    chart = new google.visualization.AnnotatedTimeLine(chart_el)
54                    break;
55                case 'annotation':
56                    chart = new google.visualization.AnnotationChart(chart_el)
57                    break;
58                case 'area':
59                    chart = new google.visualization.AreaChart(chart_el);
60                    break;
61                case 'bar':
62                    chart = new google.visualization.BarChart(chart_el);
63                    break;
64                case 'bubble':
65                    chart = new google.visualization.BubbleChart(chart_el);
66                    break;
67                case 'candlestick':
68                    chart = new google.visualization.CandlestickChart(chart_el);
69                    break;
70                case 'column':
71                default:
72                    chart = new google.visualization.ColumnChart(chart_el);
73                    break;
74                case 'combo':
75                    chart = new google.visualization.ComboChart(chart_el);
76                    break;
77                case 'gauge':
78                    chart = new google.visualization.Gauge(chart_el);
79                    break;
80                case 'geo':
81                    chart = new google.visualization.GeoChart(chart_el);
82                    break;
83                case 'histogram':
84                    chart = new google.visualization.Histogram(chart_el);
85                    break;
86                case 'line':
87                    chart = new google.visualization.LineChart(chart_el);
88                    break;
89                case 'pie':
90                    chart = new google.visualization.PieChart(chart_el);
91                    break;
92                case 'scatter':
93                    chart = new google.visualization.ScatterChart(chart_el);
94                    break;
95                case 'stepped':
96                case 'steppedarea':
97                    chart = new google.visualization.SteppedAreaChart(chart_el);
98                    break;
99                case 'timeline':
100                    chart = new google.visualization.Timeline(chart_el);
101                    break;
102            }
103            chart.draw(data, options);
104        });
105
106        // Chart helpers.
107        function stripPrefixInKeys (prefix, obj) {
108            var new_obj = {};
109            for (x in obj) {
110                if (0 === x.indexOf(prefix)) {
111                    new_obj[x.slice(prefix.length)] = obj[x];
112                } else {
113                    new_obj[x] = obj[x];
114                }
115            }
116            return new_obj;
117        }
118        function lowerFirstCharInKeys (obj) {
119            var new_obj = {};
120            for (x in obj) {
121                new_obj[x.charAt(0).toLowerCase() + x.slice(1)] = obj[x];
122            }
123            return new_obj;
124        }
125    });
126});
127
128})(); // end IIFE

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.