You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@superset.apache.org by GitBox <gi...@apache.org> on 2019/03/28 05:33:55 UTC

[GitHub] [incubator-superset] Narcissus7 commented on issue #5941: Filter dashboard clicking on chart

Narcissus7 commented on issue #5941: Filter dashboard clicking on chart
URL: https://github.com/apache/incubator-superset/issues/5941#issuecomment-477454936
 
 
   In `visualizations` , every chart file has  `transformProps.js` 
   You can find `chartProps` which contains `onAddFilter()` function already.
   The function is `src/dashboard/actions/dashboardState.changeFilter()`
   
   Take `Sankey` as an example:
   `transformProps.js` \:
   ```
   export default function transformProps(chartProps) {
     const { ... onAddFilter } = chartProps;
     const { ... groupby } = formData;
   
     return {
       ...
       onAddFilter,  // add. filter function
       groupby,    // add. filter field
     };
   }
   ```
   `Sankey.js`\:
   ```
   // ... receive onAddFilter and groupby
   let centered;  // add
   const link = svg.append('g').selectAll('.link')
       ......
       .on('click', function (d) {    // add filter on link
         if(d && centered !== d){
           addFilter(groupby[0], d.source.name, false, false);  // d.source.name: filter value
           addFilter(groupby[1], d.target.name, false, true);
           centered = d;
         } else {   // second click to clear filter
           addFilter(groupby[0], [], false, false);
           addFilter(groupby[1], [], false, true);
           centered = null;
         }
         d3.event.stopPropagation();
   })
   ```
   This method may apply only to a part of the charts.And the way to get filtered fields/values is not the same.
   The implementation of each chart is quite different.
   (e.g. click event of  Pie is `chart.pie.dispatch.on("elementClick", function(e) {})`)

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org