Okay
  Public Ticket #3022045
Line chart should point should not been shown when cell is empty
Closed

Comments

  • Chris started the conversation

    We imported a table and generated a line chart from it. Some rows doesnt have data and we dont want the point to be shown in the chart. Is this possible?

    See attached screenshot

  •  1,851
    Miloš replied

    Hi, Chris

    Thanks for reaching out to us

    I am not 100 % sure if this is possible, to be fully honest with you,

    but i will certainly make sure to check with our senior 2nd level Team, if there is a workaround to achieve this.

    For example, we can easily hide rows on the table itself with Conditional rules, that if a cell is empty, to hide the entire row with CSS > but this is only affecting the table; the chart is still pulling all the values...

    9300170802.png
    1198794083.png


    9546421503.png

    but on the chart they still show:

    7210083428.png

    so, i will check if we got any workaround, and i will come back to you.  Sorry for the waiting time. Thanks.

    Kind Regards, 

    Miloš Jovanović
    [email protected]

    Rate my support

    Try our FREE mapping plugin! MapSVG - easy Google maps, interactive SVG maps and floor plans, choropleth maps and much more - https://wordpress.org/plugins/mapsvg-lite-interactive-vector-maps/

    wpDataTables: FAQ | Facebook | Twitter | InstagramFront-end and back-end demo | Docs

    Amelia: FAQ | Facebook | Twitter | InstagramAmelia demo sites | Docs | Discord Community

    You can try wpDataTables add-ons before purchasing on these sandbox sites:

    Powerful Filters | Gravity Forms Integration for wpDataTables | Formidable Forms Integration for wpDataTables | Master-Detail Tables

  • Chris replied

    Thanks for checking. 

    Bottomline, I want to have the line chart start from the moment there is actual data.

    Thanks again!

  •  1,851
    Miloš replied

    Hi, Chris

    Seems that we have a workaround for you.smile.png  Please try this:

    Please go to the functions.php file of your theme or child theme, and add this:

    function filterNullValues ($value, $origHeader ,$chartID, $tableID){  
       // You can add conditions for specific org header, chart id or table id 
       // Here we only check if value is null and provide same value to the chart object
     if (is_null($value) || $value == 0){    
        $value = null;  
      }    return $value;
    }
    add_filter( 'wpdatatables_filter_int_cell_data_in_charts', 'filterNullValues', 10, 4 );
    add_filter( 'wpdatatables_filter_float_cell_data_in_charts', 'filterNullValues', 10, 4 );

    This works for integer and float columns that have NULL values and "0" values.

    If you want to apply it just for NULL values, you can use this code:

    function filterNullValues ($value, $origHeader ,$chartID, $tableID){  
       // You can add conditions for specific org header, chart id or table id 
       // Here we only check if value is null and provide same value to the chart object 
       if (is_null($value)){        $value = null;  
      }    return $value;
    }
    add_filter( 'wpdatatables_filter_int_cell_data_in_charts', 'filterNullValues', 10, 4 );
    add_filter( 'wpdatatables_filter_float_cell_data_in_charts', 'filterNullValues', 10, 4 );

    And if you want to apply it just for "0" values, you can use this code:

    function filterNullValues ($value, $origHeader ,$chartID, $tableID){  
       // You can add conditions for specific org header, chart id or table id 
       // Here we only check if value is null and provide same value to the chart object  
      if ($value == 0){   
         $value = null;  
      }  
      return $value;
    }
    add_filter( 'wpdatatables_filter_int_cell_data_in_charts', 'filterNullValues', 10, 4 );
    add_filter( 'wpdatatables_filter_float_cell_data_in_charts', 'filterNullValues', 10, 4 );
    

    You don't need to change the code after the plugin updates, but you will need to keep this code in functions.php.

    If you want to connect data with NULLs skipped, you can use this callback: https://jsfiddle.net/gh/get/library/pure/highcharts/highcharts/tree/master/samples/highcharts/plotoptions/series-connectnulls-true/

    <script type="text/javascript">
    jQuery(window).on('load',function(){   
     if( typeof wpDataChartsCallbacks == 'undefined' ){   
          wpDataChartsCallbacks = {};
     } 
       wpDataChartsCallbacks[16] = function(obj){   
         obj.options.plotOptions = {     
           series: {         
           connectNulls: true      
              }  
          }  
      };
    });
    </script>
    

    Just make sure to replace [16] with the ID of your chart.

    -

    Let me know if that helps. Thank you

    Kind Regards, 

    Miloš Jovanović
    [email protected]

    Rate my support

    Try our FREE mapping plugin! MapSVG - easy Google maps, interactive SVG maps and floor plans, choropleth maps and much more - https://wordpress.org/plugins/mapsvg-lite-interactive-vector-maps/

    wpDataTables: FAQ | Facebook | Twitter | InstagramFront-end and back-end demo | Docs

    Amelia: FAQ | Facebook | Twitter | InstagramAmelia demo sites | Docs | Discord Community

    You can try wpDataTables add-ons before purchasing on these sandbox sites:

    Powerful Filters | Gravity Forms Integration for wpDataTables | Formidable Forms Integration for wpDataTables | Master-Detail Tables

  • Chris replied

    Awesome, the php snippet did the trick. Thank you very much!

    Chris

  •   Miloš replied privately