How to automatically sync charts with online files

πŸ“ Note: The steps provided in this article can be applied only to online files. To create an online file, please refer to this doc.

Sometimes you find yourself in a situation where you have a spreadsheet that you  regularly update, and you want the chart to reflect the changes. Visualizer brings a feature that you can use to sync the data on a specific time interval, which you can set when creating the chart. 

This article will present how to use the automatic syncing option and how to create custom import intervals.

πŸ“ Note: In order to have the full set of options, at least the Visualizer Personal Plan is required.


πŸ—‚ Default import intervals

1

Navigate to Dashboard > Visualizer > Charts Library.

2

Pick the chart that you want to be always up to date and open its settings.

3

Under the Source tab, expand Import data from URL and Import from CSV.

4

Under the link of the live source, use the dropdown to establish an import schedule.


βš™οΈ Custom import intervals

The Visualizer plugin provides a feature to synchronize your chart data with a remote CSV file. The minimum time interval is one hour when the plugin checks the file URL. If you want to use a smaller interval than an hour to check the file more often, follow these steps:

1

Copy this code snippet:

add_filter('visualizer_chart_schedules', 'visualizer_chart_schedules', 10, 3);
function visualizer_chart_schedules( $schedules, $type, $chart_id) {
	if($type === 'csv'){
		$schedules = array_merge(
			$schedules,
			array(
				'0.1' => __( 'Every 6 minutes', 'visualizer' ),
			)
		);
	}
	return $schedules;
}

// these 2 functions are for the cron. the interval chosen here should be smaller or equal to than the interval chosen above.
add_filter('visualizer_chart_schedule_interval', 'visualizer_chart_schedule_interval', 10, 1);
function visualizer_chart_schedule_interval($default){
	$default = 'every_minute';
	return $default;
}

add_filter('cron_schedules', 'cron_schedules', 10, 1);
function cron_schedules($schedules){
	$schedules['every_minute'] = array(
		'interval' => 60,
		'display' => __('Every Minute')
	);
	return $schedules;
}
2

Replace the intervals from the code to fit your needs.

3

Paste the code into the plugin's file.

4

Save the changes, then check the available intervals again.

πŸ’‘Result

Did this answer your question? Thanks for the feedback There was a problem submitting your feedback. Please try again later.

Still need help? Contact Us Contact Us