I have a simple table from a webform survey as per the attachment.

I cannot configure the table to show the labels correctly. They show as the number of votes, not as the labels in column 1.

Can anyone assist?

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

GrahamShepherd’s picture

GrahamShepherd’s picture

GrahamShepherd’s picture

Issue summary: View changes
RdeBoer’s picture

FileSize
95.84 KB

Hi Graham,

Thank you for your report.

I was able to confirm your issue with my own dataset (see screenshot; not a Webform, but that is irrelevant anyway).
Basically the pie chart is correct, but the legend shows the "Y" values rather than the names ("X" values).
When one hovers over a piece of the pie, the correct pairing X: Y displays.

This is likely an issue outside this module.
I checked this issue queue: https://github.com/highchartTable/jquery-highchartTable-plugin/issues, but could not find anything.

I'll run the debugger over it some time soon to confirm.

Rik

RdeBoer’s picture

Title: Pie chart labels not configurable or not showing correctly » Pie chart legend replicates Y values rather than "X"
Assigned: Unassigned » RdeBoer
RdeBoer’s picture

Category: Support request » Bug report
apmsooner’s picture

FileSize
75.82 KB

What it sounds like here is the ability to choose a column number to extract the value from to serve as the legend label. The example from highcharts table is showing this ability by passing a data attribute:

<table class="highchart" data-graph-container-before="1" data-graph-type="pie" style="display:none" data-graph-datalabels-enabled="1">
    <thead>
        <tr>                                  
            <th>Month</th>
            <th>Sales</th>
        </tr>
     </thead>
     <tbody>
        <tr>
            <td>January</td>
            <td data-graph-name="January" data-graph-item-color="#ccc">8000</td>
        </tr>
        <tr>
            <td>February</td>
            <td data-graph-name="February">12000</td>
        </tr>
        <tr>
            <td>March</td>
            <td data-graph-name="March">18000</td>
        </tr>
    </tbody>
</table>

For tables generated by views, it would be nice feature to be able to set data attributes at the field level much like classes are set. Rick, is there any way of setting this perhaps from a column number in the chart configuration aside from a feature request on the views module?

RdeBoer’s picture

@apmsooner,

I feel we can safely rule out a Feature Request on the Views module for this.

Will have to look at our code to see what we can do in our module.

Rik

apmsooner’s picture

@rick,
Idea:
Could an integer input field be added to the chart settings to determine a column number to pull for series name per the functionality added here: https://www.drupal.org/node/2423367

Per this example http://jsfiddle.net/gh/get/jquery/1.9.1/highslide-software/highcharts.co..., the :name is determining the legend i think it could be passed in through highChartConfig?

apmsooner’s picture

Here's an additional little hacky solution that works for views....

1. copy views-view-table.tpl.php file into theme folder
2. add data attribute to <td> tag using the field class variable:

          <td <?php if ($field_classes[$field][$row_count]) { print 'class="'. $field_classes[$field][$row_count] . '" data-graph-name="' . $field_classes[$field][$row_count] . '" '; } ?><?php print drupal_attributes($field_attributes[$field][$row_count]); ?>>
            <?php print $content; ?>
          </td>

3. Under style options, uncheck default classes and add token from field you want to use as the legend label for the field class. See attached screenshot.

I think there could be a case for adding a contrib module that would add a fieldset for each field setting form called "Attributes" with modified views templates that output the variables. I'm not sure how to tap into the views api to implement such a task but this little workaround might help someone for now...

RdeBoer’s picture

@apmsooner: Thanks for your investigations and solutions.
Want to have a go at implementing #9 yourself? You have commit rights!
Rik

bisonbleu’s picture

Solution in #10 works but step 1 and 2 need to be updated as follows.

  1. copy views-aggregator-results-table.tpl.php file into your theme folder
  2. in this tpl, add data attribute to <td> tag using the field class variable i.e. replace <td>...</td> with the code below.
<td <?php if (!empty($td_class)): ?>class="<?php print $td_class . '" data-graph-name="' . $td_class; ?>"<?php endif ?>
  <?php if (!empty($field_attributes[$field][$r])): ?><?php print drupal_attributes($field_attributes[$field][$r]); ?><?php endif ?>>
  <?php print $content; ?>
</td>
rajngrg09’s picture

#10 worked. Thanks