Help with a dashboard required

43 views
Skip to first unread message

Charlie Clark

unread,
May 22, 2013, 8:02:22 AM5/22/13
to google-visua...@googlegroups.com
Hi,

I thought I'd give a the dashboard a try. I'd like to be able to filter by column name. Am I correct in thinking that this is not possible? I'd like the range slide not to contain any of the lines from the main chart.

This is the code:

<a href="#cdns" name="cdns">
<div id="cdns">
<div id="filter"></div>
<div id="chart" ></div>
</div> </a>
<script> google.setOnLoadCallback(trend_cdns) function trend_cdns() { var data = new google.visualization.DataTable({"rows": [{"c": [{"v": "Date(2012, 9, 1)"}, {"v": 4}, {}, {"v": 2}, {}, {"v": 1}, {}, {"v": 23}, {}, {}, {}, {"v": 1}, {}, {}, {"v": 1}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}]}, {"c": [{"v": "Date(2012, 9, 15)"}, {"v": 5}, {}, {"v": 2}, {}, {"v": 1}, {}, {"v": 23}, {}, {}, {}, {"v": 1}, {}, {}, {"v": 1}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}]}, {"c": [{"v": "Date(2012, 10, 1)"}, {"v": 5}, {}, {"v": 2}, {}, {"v": 1}, {}, {"v": 23}, {}, {}, {}, {"v": 1}, {}, {}, {"v": 1}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}]}, {"c": [{"v": "Date(2012, 10, 15)"}, {"v": 5}, {}, {"v": 2}, {}, {"v": 1}, {}, {"v": 23}, {}, {}, {}, {"v": 1}, {}, {}, {"v": 2}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {"v": 1}, {}, {}, {}, {}, {}, {}, {}, {}, {}]}, {"c": [{"v": "Date(2012, 11, 1)"}, {"v": 5}, {}, {"v": 2}, {}, {"v": 1}, {}, {"v": 23}, {}, {}, {}, {"v": 1}, {}, {}, {"v": 2}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {"v": 1}, {}, {}, {}, {}, {}, {}, {}, {}, {}]}, {"c": [{"v": "Date(2012, 11, 15)"}, {"v": 6}, {}, {"v": 2}, {}, {"v": 1}, {}, {"v": 23}, {}, {}, {}, {"v": 1}, {}, {}, {"v": 2}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}]}, {"c": [{"v": "Date(2013, 0, 1)"}, {"v": 5}, {}, {"v": 1}, {}, {"v": 1}, {}, {"v": 23}, {}, {}, {}, {"v": 1}, {}, {}, {"v": 2}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {"v": 1}, {}, {}, {}]}, {"c": [{"v": "Date(2013, 0, 15)"}, {"v": 6}, {}, {"v": 1}, {}, {"v": 1}, {}, {"v": 23}, {}, {}, {}, {"v": 1}, {}, {}, {"v": 2}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {"v": 1}, {}, {}, {}]}, {"c": [{"v": "Date(2013, 1, 1)"}, {"v": 6}, {}, {"v": 1}, {}, {"v": 1}, {}, {"v": 23}, {}, {}, {}, {"v": 1}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}]}, {"c": [{"v": "Date(2013, 1, 15)"}, {"v": 6}, {}, {"v": 1}, {}, {"v": 1}, {}, {"v": 23}, {}, {}, {}, {"v": 1}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}]}, {"c": [{"v": "Date(2013, 2, 1)"}, {"v": 6}, {}, {"v": 1}, {}, {"v": 1}, {}, {"v": 23}, {}, {}, {}, {"v": 1}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}]}, {"c": [{"v": "Date(2013, 2, 15)"}, {"v": 6}, {}, {"v": 1}, {}, {"v": 1}, {}, {"v": 22}, {}, {}, {}, {"v": 1}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}]}, {"c": [{"v": "Date(2013, 3, 1)"}, {"v": 6}, {}, {"v": 1}, {}, {"v": 1}, {}, {"v": 23}, {}, {}, {}, {"v": 1}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}]}, {"c": [{"v": "Date(2013, 3, 15)"}, {"v": 6}, {}, {"v": 1}, {}, {"v": 1}, {}, {"v": 23}, {}, {}, {}, {"v": 2}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}]}, {"c": [{"v": "Date(2013, 4, 1)"}, {"v": 6}, {}, {"v": 1}, {}, {"v": 1}, {}, {"v": 23}, {}, {}, {}, {"v": 2}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}]}, {"c": [{"v": "Date(2013, 4, 15)"}, {"v": 6}, {}, {"v": 1}, {}, {"v": 1}, {}, {"v": 23}, {}, {}, {}, {"v": 2}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}]}], "cols": [{"type": "date", "id": "Date", "label": "Date"}, {"type": "number", "id": "Akamai", "label": "Akamai"}, {"type": "number", "id": "Amazon CloudFront", "label": "Amazon CloudFront"}, {"type": "number", "id": "CDNetworks", "label": "CDNetworks"}, {"type": "number", "id": "Cloudflare", "label": "Cloudflare"}, {"type": "number", "id": "Cotendo CDN", "label": "Cotendo CDN"}, {"type": "number", "id": "Edgecast", "label": "Edgecast"}, {"type": "number", "id": "Google", "label": "Google"}, {"type": "number", "id": "Incapsula", "label": "Incapsula"}, {"type": "number", "id": "Level 3", "label": "Level 3"}, {"type": "number", "id": "Limelight", "label": "Limelight"}, {"type": "number", "id": "lxdns.com", "label": "lxdns.com"}, {"type": "number", "id": "Mirror Image", "label": "Mirror Image"}, {"type": "number", "id": "NetDNA", "label": "NetDNA"}, {"type": "number", "id": "Taobao", "label": "Taobao"}, {"type": "number", "id": "afxcdn.net", "label": "afxcdn.net"}, {"type": "number", "id": "AT&amp;T", "label": "AT&amp;T"}, {"type": "number", "id": "BitGravity", "label": "BitGravity"}, {"type": "number", "id": "BO.LT", "label": "BO.LT"}, {"type": "number", "id": "Cachefly", "label": "Cachefly"}, {"type": "number", "id": "CDN77", "label": "CDN77"}, {"type": "number", "id": "cubeCDN", "label": "cubeCDN"}, {"type": "number", "id": "Fastly", "label": "Fastly"}, {"type": "number", "id": "Highwinds", "label": "Highwinds"}, {"type": "number", "id": "Internap", "label": "Internap"}, {"type": "number", "id": "NGENIX", "label": "NGENIX"}, {"type": "number", "id": "OnApp", "label": "OnApp"}, {"type": "number", "id": "Panther", "label": "Panther"}, {"type": "number", "id": "VoxCDN", "label": "VoxCDN"}, {"type": "number", "id": "Windows Azure", "label": "Windows Azure"}, {"type": "number", "id": "Yottaa", "label": "Yottaa"}, {"type": "number", "id": "Yahoo", "label": "Yahoo"}, {"type": "number", "id": "Simple CDN", "label": "Simple CDN"}, {"type": "number", "id": "ChinaCache", "label": "ChinaCache"}, {"type": "number", "id": "Azion", "label": "Azion"}, {"type": "number", "id": "MediaCloud", "label": "MediaCloud"}, {"type": "number", "id": "OVH CDN", "label": "OVH CDN"}]});

var options = { title : "CDN Trends", width: 600, };
var dashboard = new google.visualization.Dashboard( document.getElementById('cdns'));
var RangeSlider = new google.visualization.ControlWrapper({ 'controlType': 'ChartRangeFilter', 'containerId': 'filter', 'options': { 'filterColumnLabel': 'Date' } });
var chart = new google.visualization.ChartWrapper({ 'chartType': 'LineChart', 'containerId': 'chart', 'options':options });
dashboard.bind(RangeSlider, chart);
dashboard.draw(data, options); }
</script>

Thanks

Charlie


Charlie Clark

unread,
May 22, 2013, 11:04:19 AM5/22/13
to google-visua...@googlegroups.com
Am 22.05.2013, 14:02 Uhr, schrieb Charlie Clark
<charli...@clark-consulting.eu>:

> Hi,
> I thought I'd give a the dashboard a try. I'd like to be able to filter
> by
> column name. Am I correct in thinking that this is not possible? I'd like
> the range slide not to contain any of the lines from the main chart.

Okay. I think I've figured out the basics of using the control and I can
probably use a dataView for my column inclusion exclusion.

I think I've hit a bug on the options for the controls' chartOptions: the
width parameter only seems to respond to % values.

var options = {
title : "CDN Trends",
width: 600,
legend: {position: 'top'}
};


var dashboard = new google.visualization.Dashboard(
document.getElementById('cdns'));

var control = new google.visualization.ControlWrapper({
'controlType': 'ChartRangeFilter',
'containerId': 'filter',
'options': {
'filterColumnLabel': 'Date',
'ui': {
'chartType': 'LineChart',
'chartOptions': {
'chartArea': {
'width': 600,
'height': 50
},
'hAxis': {'baselineColor': 'none',
'textPosition': 'none'},
'position': 'left'
},
'chartView': {'columns': [0, 1]},
}
}
});

var chart = new google.visualization.ChartWrapper({
'chartType': 'LineChart',
'containerId': 'chart',
'options':options
});

dashboard.bind(control, chart);
dashboard.draw(data, options);
}

Displays as per enclosed screenshot: the control uses a default width and
is indented. Is this a bug? If not, how can I fix it?

Charlie
--
Charlie Clark
Managing Director
Clark Consulting & Research
German Office
Kronenstr. 27a
Düsseldorf
D- 40217
Tel: +49-211-600-3657
Mobile: +49-178-782-6226
Bildschirmfoto 2013-05-22 um 16.58.48.png

asgallant

unread,
May 22, 2013, 11:57:54 AM5/22/13
to google-visua...@googlegroups.com
Set the controls's options.ui.chartOptions.width to control the width of the filter:

var control = new google.visualization.ControlWrapper({ 
    'controlType': 'ChartRangeFilter', 
    'containerId': 'filter', 
    'options': { 
        'filterColumnLabel': 'Date', 
        'ui': { 
            'chartType': 'LineChart', 
            'chartOptions': {
                width: 600,
                height: 50,
                'chartArea': {
                    // set the chartaArea.width to a percentage value that is the same
                    // as the chartArea.width of the chart, so they line up properly
                    'width': 'XX%'
                }, 
                'hAxis': {
                    'baselineColor': 'none', 
                    'textPosition': 'none'
                }, 
                'position': 'left' 
            }, 
            'chartView': {'columns': [0, 1]}, 
        } 
    } 
}); 

Also, if you want to be able to filter by column names, I wrote a hack that turns a CategoryFilter into a column filter: http://jsfiddle.net/asgallant/WaUu2/

Charlie Clark

unread,
May 23, 2013, 6:41:21 AM5/23/13
to google-visua...@googlegroups.com
Hi,

Am 22.05.2013, 17:57 Uhr, schrieb asgallant <drew_g...@abtassoc.com>:

> Set the controls's options.ui.chartOptions.width to control the width of
> the filter:
> var control = new google.visualization.ControlWrapper({
> 'controlType': 'ChartRangeFilter',
> 'containerId': 'filter',
> 'options': {
> 'filterColumnLabel': 'Date',
> 'ui': {
> 'chartType': 'LineChart',
> 'chartOptions': {
> width: 600,
> height: 50,
> 'chartArea': {
> // set the chartaArea.width to a percentage value
> that
> is the same
> // as the chartArea.width of the chart, so they line
> up
> properly

Thanks. Difficult sometimes to see the wood for the trees with these
nested options and no ability to set attributes directly.


> Also, if you want to be able to filter by column names, I wrote a hack
> that
> turns a CategoryFilter into a column filter:
> http://jsfiddle.net/asgallant/WaUu2/

Very interesting, thanks.
Reply all
Reply to author
Forward
0 new messages