If I create a view with an exposed filter and ajax enabled in a block, the chart displays nicely with the filter above it. However, when I try to change the filter (I want to view a chart showing a different vocabulary), the chart disappears. Inspecting the source code, it got the right terms, but the counts all came up as zero. No javascript errors, and nothing in the Drupal logs. Here's the view code:

$view = new view;
$view->name = 'dped_charts';
$view->description = '';
$view->tag = '';
$view->view_php = '';
$view->base_table = 'term_data';
$view->is_cacheable = FALSE;
$view->api_version = 2;
$view->disabled = FALSE; /* Edit this to true to make a default view disabled initially */
$handler = $view->new_display('default', 'Defaults', 'default');
$handler->override_option('relationships', array(
  'vid' => array(
    'id' => 'vid',
    'table' => 'term_node',
    'field' => 'vid',
  ),
));
$handler->override_option('fields', array(
  'name' => array(
    'id' => 'name',
    'table' => 'term_data',
    'field' => 'name',
  ),
  'tid' => array(
    'id' => 'tid',
    'table' => 'term_data',
    'field' => 'tid',
  ),
  'nid' => array(
    'label' => 'Count',
    'alter' => array(
      'alter_text' => 0,
      'text' => '',
      'make_link' => 0,
      'path' => '',
      'link_class' => '',
      'alt' => '',
      'prefix' => '',
      'suffix' => '',
      'target' => '',
      'help' => '',
      'trim' => 0,
      'max_length' => '',
      'word_boundary' => 1,
      'ellipsis' => 1,
      'html' => 0,
      'strip_tags' => 0,
    ),
    'empty' => '',
    'hide_empty' => 0,
    'empty_zero' => 0,
    'link_to_node' => 0,
    'exclude' => 0,
    'id' => 'nid',
    'table' => 'node',
    'field' => 'nid',
    'relationship' => 'vid',
  ),
  'views_sql_groupedfields' => array(
    'label' => 'Group By Fields',
    'alter' => array(
      'alter_text' => FALSE,
      'text' => '',
      'make_link' => FALSE,
      'path' => '',
      'alt' => '',
      'link_class' => '',
      'prefix' => '',
      'suffix' => '',
      'target' => '',
      'trim' => FALSE,
      'max_length' => '',
      'word_boundary' => TRUE,
      'ellipsis' => TRUE,
      'strip_tags' => FALSE,
      'html' => FALSE,
    ),
    'empty' => '',
    'hide_empty' => 0,
    'empty_zero' => 0,
    'exclude' => '1',
    'id' => 'views_sql_groupedfields',
    'table' => 'views_groupby',
    'field' => 'views_sql_groupedfields',
    'relationship' => 'none',
    'views_groupby_fields_to_group' => array(
      'tid' => 'tid',
    ),
    'views_groupby_sql_function' => 'count',
    'views_groupby_fields_to_aggregate' => array(
      'nid' => 'nid',
    ),
    'views_groupby_field_sortby' => 'nid',
    'views_groupby_sortby_direction' => 'asc',
  ),
));
$handler->override_option('filters', array(
  'vid' => array(
    'operator' => 'in',
    'value' => array(
      '1' => '1',
    ),
    'group' => '0',
    'exposed' => TRUE,
    'expose' => array(
      'use_operator' => 0,
      'operator' => 'vid_op',
      'identifier' => 'X-Axis',
      'label' => 'Taxonomy: Vocabulary',
      'bef_filter_description' => '',
      'bef_format' => 'default',
      'optional' => 1,
      'single' => 1,
      'remember' => 0,
      'reduce' => 0,
      'bef_select_all_none' => 0,
    ),
    'id' => 'vid',
    'table' => 'term_data',
    'field' => 'vid',
    'relationship' => 'none',
    'override' => array(
      'button' => 'Override',
    ),
  ),
));
$handler->override_option('access', array(
  'type' => 'none',
));
$handler->override_option('cache', array(
  'type' => 'none',
));
$handler->override_option('use_ajax', TRUE);
$handler->override_option('items_per_page', 0);
$handler->override_option('style_plugin', 'charts');
$handler->override_option('style_options', array(
  'views_charts_series_fields' => array(
    'name' => 'name',
  ),
  'views_charts_x_labels' => 'name',
  'width' => '295',
  'height' => '295',
  'engine' => 'bluff',
  'type' => array(
    'bluff' => 'pie',
  ),
  'wmode' => 'window',
  'y_min' => '0',
  'y_legend' => 'Shares of Total',
));
$handler = $view->new_display('block', 'Block', 'block_1');
$handler->override_option('block_description', '');
$handler->override_option('block_caching', -1);

Comments

seanr’s picture

Even in a page with ajax off, only one vocabulary works. If I change the view style to HTML List, the numbers show up correctly. Only views_charts isn't working right.

seanr’s picture

OK, the full page with ajax off not working was a config issue (had the charts mapped to the wrong field), so that now works, but the ajax block still does not. The table in the DOM updates, but the chart doesn't render. I guess we need to output the jquery stuff inline in the theme function instead of the page footer?

seanr’s picture

Title: Exposed filters with ajax in a block causes chart to disappear on apply » Bluff Charts incompatible with ajax
Project: Views Charts » Charts and Graphs
Version: 6.x-1.0-rc1 » 6.x-1.0-rc2

I think this is a charts and graphs issue, not specific to views, so moving it there.

rsevero’s picture

If I'm understanding correctly this isn't a Charts and Graphs issue. You need to manage to call all javascript code beginning with

        g.data_from_table("bluffchart-8", true);

all the way down to

        $("#bluffchart-8-graph")
          .parent("div.bluff-wrapper")
          .append(legend.join(""))
          .css({height: "auto"});

to get an up to date chart.

Maybe this could be done by Charts and Graphs using Drupal behaviors, I'm not sure.

rsevero’s picture

Version: 6.x-1.0-rc2 » 6.x-1.x-dev
Assigned: Unassigned » rsevero
Status: Active » Fixed

I might have fixed this issue with commit #384668 by attaching a behavior that calls the chart drawing function. I can't be sure as I can't reproduce the problem here.

Please reopen if necessary.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.