Graphina Documentation

Retrieving Dynamic Data Using WordPress Filters

The WordPress filter functionality allows users to fetch and modify dynamic data effortlessly. By utilizing the graphina_extra_data_option filter, you can integrate custom data into Graphina charts and widgets.

How to Use the WordPress Filter for Dynamic Data

To enable this feature, add the Graphina filter to any WordPress file. A common practice is to include it in the functions.php file of your active theme.

Example Use Cases

The filter provides structured data for various chart types, including:

  • Pie, Donut, Radial, Polar Charts – Returns category-based data for these visualizations.
  • Area, Column, Brush, Mixed, Line, Radar, Distributed Column Charts – Returns multi-series data.
  • Data Tables (Lite & Advanced) – Returns tabular data with headers and body content.
  • Counters – Configures counter elements with speed, start, and end values.

Implementation Notes

  • Ensure the Graphina filter is correctly added to your theme’s functions.php.
  • Use this filter to customize chart data dynamically without modifying each chart manually.
  • Adjust priority and accepted arguments as needed to fit your project requirements.

This feature enhances the flexibility of Graphina dynamic charts, allowing seamless integration of real-time WordPress data.

//$data -> sample data

//$type -> type of widget (line, area)

//$settings -> elementor setting array

//$widgetId -> Id of elementor widget ( each widget have a unique id)

add_filter(‘graphina_extra_data_option’,function($data, $type, $settings,$widgetId){

          if($type == ‘pie’ || $type == ‘donut’ || $type == ‘radial’ || $type == ‘polar’ ){

                 return [

                        ‘series’ => [52, 62,48,52 ],

                        ‘category’ =>  [ “Jan”, “Feb”, “Mar”,  “Apr” ],

                        ‘total’=>542

                   ];

            }

            if($type == ‘area’ || $type == ‘column’ || $type == ‘brush’ || $type == ‘mixed’ || $type == ‘line’ || $type == ‘radar’ || $type == ‘distrubuted_column’){

                    return [ ‘series’ => [

                           [

                            ‘name’ => ‘elem’,

                            ‘data’ => [ 52,58,585,14]

                           ]

                     ],

‘category’ => [ ‘Jan’, ‘Feb’, ‘Mar’, ‘Apr’ ]

                     ];

              }

             if($type === ‘data_table_lite’ || $type == ‘advance-datatable’){

                    return [

                        ‘body’ => [

                            [‘abc’ , ‘xyz’],

                            [‘rtl’ , ‘yzr’]

                        ],

                        ‘header’ => [‘firstname’,’lastname’]

                    ];

             }

            if($type == ‘counter’){

                   return [ [‘title’ => ‘filter’,

                       ‘speed’ => 1200,

                       ‘start’ => 0,

                       ‘end’ => 8025,

                       ‘multi’ => []

                   ]];

             }

  }, $priority, $accepted_args);