Do motion charts work inside dashboards?

165 views
Skip to first unread message

rtrigg

unread,
Dec 9, 2011, 2:22:59 PM12/9/11
to Google Visualization API, rtr...@globalfundforwomen.org
Hi all,

I'm having trouble getting my motion chart to successfully bind to a
controller in a dashboard. In the example below, I've taken the code
from the MotionChart viz documentation and turned it into a dashboard
with one controller. The page displays fine, but choosing an item
from the category filter has no effect on the motion chart.

Ideas?

Thanks!

- Randy

<html>
<head>
<script type="text/javascript" src="https://www.google.com/
jsapi"></script>
<script type="text/javascript">
google.load('visualization', '1', {'packages':['corechart',
'controls', 'motionchart']});
google.setOnLoadCallback(drawChart);
function drawChart() {
var data = new google.visualization.DataTable();
data.addColumn('string', 'Fruit');
data.addColumn('date', 'Date');
data.addColumn('number', 'Sales');
data.addColumn('number', 'Expenses');
data.addColumn('string', 'Location');
data.addRows([
['Apples',new Date (1988,0,1),1000,300,'East'],
['Oranges',new Date (1988,0,1),1150,200,'West'],
['Bananas',new Date (1988,0,1),300,250,'West'],
['Apples',new Date (1989,6,1),1200,400,'East'],
['Oranges',new Date (1989,6,1),750,150,'West'],
['Bananas',new Date (1989,6,1),788,617,'West']
]);

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

var locationPicker = new google.visualization.ControlWrapper({
'controlType': 'CategoryFilter',
'containerId': 'locationPicker_div',
'options': {
'filterColumnIndex': 4,
}
});

var chart = new google.visualization.ChartWrapper({
'chartType': 'MotionChart',
'containerId': 'chart_div',
'options': {width: 600, height:300}
});

dashboard.bind(locationPicker, chart);
dashboard.draw(data);
}
</script>
</head>

<body>
<div id="dashboard_div">
<div id="locationPicker_div"></div>
<div id="chart_div" style="width: 600px; height: 300px;"></div>
</div>
</body>
</html>

Roni Biran

unread,
Dec 11, 2011, 3:17:19 AM12/11/11
to google-visua...@googlegroups.com, rtr...@globalfundforwomen.org
According to the documentation there should not be any problems. Also it appears that your code should run.
Are you trying to run it locally? You might have flash security issues since the MotionChart is in fact a flash object.





--
You received this message because you are subscribed to the Google Groups "Google Visualization API" group.
To post to this group, send email to google-visua...@googlegroups.com.
To unsubscribe from this group, send email to google-visualizati...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/google-visualization-api?hl=en.


rtrigg

unread,
Dec 11, 2011, 11:23:48 AM12/11/11
to Google Visualization API
Yeah, I thought of that. First, it behaves the same whether I run
from localhost or at a remote site. Second, the flash motion chart
works fine initially. I just can't get it to recompute when I make
the selection in the category picker. It's as though the motion chart
is caching the data and the dashboard controller isn't clearing the
data or resetting the flash or whatever needs to happen.

By the way, I tried taking the motion chart out of the dashboard, and
using a listener to redraw it when the controller's state changes.
Still no luck.

In short, either I'm doing something stupid, or there's some extra
tweak needed for resetting motion charts.

Have you gotten motion charts to play nicely in dashboards?

Thanks,

- Randy

Viz Kid

unread,
Dec 19, 2011, 5:42:21 AM12/19/11
to google-visua...@googlegroups.com

We have looked into it shortly and it seems there is indeed an issue. It is possible that the MotionChart assumed that the underlying data table is never changed and therefore changing causes some unexpected behavior.

Sorry,
  Viz Kid

Sabrina Atienza

unread,
May 31, 2012, 5:07:35 PM5/31/12
to google-visua...@googlegroups.com
Has this issue been resolved? I'm also attempting to use a Dashboard with a category filter and a motion chart. My code is similar in structure to that posted above, and the dashboard fails to draw even though the motion chart alone works wonderfully. Thanks.

Sabrina


On Monday, December 19, 2011 5:42:21 AM UTC-5, Viz Kid wrote:

We have looked into it shortly and it seems there is indeed an issue. It is possible that the MotionChart assumed that the underlying data table is never changed and therefore changing causes some unexpected behavior.

Sorry,
  Viz Kid

On Sun, Dec 11, 2011 at 6:23 PM, rtrigg <randy...@gmail.com> wrote:
Yeah, I thought of that.  First, it behaves the same whether I run
from localhost or at a remote site.  Second, the flash motion chart
works fine initially.  I just can't get it to recompute when I make
the selection in the category picker.  It's as though the motion chart
is caching the data and the dashboard controller isn't clearing the
data or resetting the flash or whatever needs to happen.

By the way, I tried taking the motion chart out of the dashboard, and
using a listener to redraw it when the controller's state changes.
Still no luck.

In short, either I'm doing something stupid, or there's some extra
tweak needed for resetting motion charts.

Have you gotten motion charts to play nicely in dashboards?

Thanks,

  - Randy

--
You received this message because you are subscribed to the Google Groups "Google Visualization API" group.
To post to this group, send email to google-visualization-api@googlegroups.com.
To unsubscribe from this group, send email to google-visualization-api+unsub...@googlegroups.com.

Jinji

unread,
Jun 3, 2012, 10:56:13 AM6/3/12
to google-visua...@googlegroups.com
I'm afraid not. There's no active work being done on the flash charts. If you don't need the play-over-time feature of MotionChart, you can use BubbleChart instead.

To view this discussion on the web visit https://groups.google.com/d/msg/google-visualization-api/-/kqzxGxdEBlkJ.
To post to this group, send email to google-visua...@googlegroups.com.
To unsubscribe from this group, send email to google-visualizati...@googlegroups.com.

leglera

unread,
Jul 11, 2012, 2:13:28 PM7/11/12
to google-visua...@googlegroups.com, rtr...@globalfundforwomen.org
I have gotten this to work - however setting the initial state seems to be an issue:


<html>
  <head>
    <script type="text/javascript" src="https://www.google.com/
jsapi"></script>
    <script type="text/javascript">
      google.load('visualization', '1', {'packages':['corechart',
'controls', 'motionchart']});
      google.setOnLoadCallback(drawChart);
      function drawChart() {
         
  var data = new google.visualization.DataTable();
   data.addColumn('string', 'Value');
   data.addColumn('number', 'Year');
 data.addColumn('number', 'Patient Count');
 data.addColumn('number', 'Value Count');
 data.addColumn('number', 'Value per Patient');
 data.addRows([
     // insert data here
['Tobacco Use',2004,41401,125839,3.04],
['Tobacco Use',2005,40204,126262,3.14],
['Tobacco Use',2006,38852,122190,3.15],
['Tobacco Use',2007,40325,136972,3.4],
['Tobacco Use',2008,42213,137113,3.25],
['Tobacco Use',2009,48059,188576,3.92],
['Tobacco Use',2010,49787,194346,3.9],
['Tobacco Use',2011,51411,215479,4.19],
['Service OP',2004,66076,601969,9.11],
['Service OP',2005,68121,654285,9.6],
['Service OP',2006,67197,688320,10.24],
['Service OP',2007,68544,691602,10.09],
['Service OP',2008,72031,711042,9.87],
['Service OP',2009,76653,766353,10],
['Service OP',2010,79025,797240,10.09],
['Service OP',2011,79752,839186,10.52],
['Service ER',2004,16783,32571,1.94],
['Service ER',2005,16785,32315,1.93],
['Service ER',2006,15899,30697,1.93],
['Service ER',2007,15959,31078,1.95],
['Service ER',2008,16356,32086,1.96],
['Service ER',2009,17655,34734,1.97],
['Service ER',2010,17487,34204,1.96],
['Service ER',2011,17576,33738,1.92],
['BMI',2004,30770,75245,2.45],
['BMI',2005,33946,89777,2.64],
['BMI',2006,37937,104375,2.75],
['BMI',2007,45073,134056,2.97],
['BMI',2008,53932,183162,3.4],
['BMI',2009,62303,217459,3.49],
['BMI',2010,65449,231372,3.54],
['BMI',2011,64889,240376,3.7],
['Blood Pressure',2004,63892,582330,9.11],
['Blood Pressure',2005,66156,602632,9.11],
['Blood Pressure',2006,65079,607740,9.34],
['Blood Pressure',2007,66171,616396,9.32],
['Blood Pressure',2008,69281,646406,9.33],
['Blood Pressure',2009,73667,700889,9.51],
['Blood Pressure',2010,75687,727682,9.61],
['Blood Pressure',2011,74141,726671,9.8],


     ]);
        var dashboard = new google.visualization.Dashboard(
                document.getElementById('dashboard_div'));
                var locationPicker = new google.visualization.ControlWrapper({
                        'controlType': 'CategoryFilter',
                        'containerId': 'locationPicker_div',
                        'options': {
                                'filterColumnIndex': 0,

                        }
            });
        var chart = new google.visualization.ChartWrapper({
                'chartType': 'MotionChart',
                'containerId': 'chart_div',
                'options': {width: 800, height:500}

        });
        dashboard.bind(locationPicker, chart);
        dashboard.draw(data);
      }
    </script>
  </head>
  <body>
   <div id="dashboard_div">
    <div id="locationPicker_div"></div>
    <div id="chart_div" style="width: 800px; height: 500px;"></div>
   </div>
  </body>
</html>
Reply all
Reply to author
Forward
0 new messages