Issue while importing data from Google Spreadsheet
-
Hi !
I have an issue while creating a line chart using an URL from a Google Spreadsheet.
Chart is fine, but i can’t edit it, i’m facing a blanck modal.Here is my logs :
[2019-07-24 12:55:50] local.ERROR: array_values() expects parameter 1 to be array, string given :"[object] (ErrorException(code: 0): array_values() expects parameter 1 to be array, string given at /var/www/html/tipy-tv/htdocs/content/plugins/visualizer/classes/Visualizer/Render/Layout.php:406)
-
@tipytv can you please provide the URL so that we can try to reproduce the issue at our end?
Sure, here is the link :
https://docs.google.com/spreadsheets/d/1hPQLfX6llCB_qW_u4uGtsUNwbNqdEJU5MxOYQmv-DPY/gviz/tq?tq=select%20A%2C%20B%20limit%2015&range=A14:B&tqx=out:csvI’ve added the second line with data types, but the issue remain the same.
Can you try again with the same url ?@tipytv please load the CSV a text editor and compare with the sample. You will see how the second row has merged with the first row.
Updated the URL for my google spreadsheet :
https://docs.google.com/spreadsheets/d/e/2PACX-1vQSolcWM_lQ0oHbNp_y-7PvG8WZtB2p3bh62lhXKqN9SYO9nlD3D9LRHUDF1ZPiKDbjVn_OX_yeCnkt/pub?gid=0&single=true&output=csvIt returns this csv :
date,nb_passagess string,number 03/08/2019,3000 04/08/2019,3100 05/08/2019,3200 06/08/2019,3300…
Directly using this csv, i can edit the chart after creating it. Using the url (that provided this csv), still have the issue π i really don’t know what to do now.
Full log trace :
[2019-07-30 08:30:53] production.ERROR: array_values() expects parameter 1 to be array, string given {"userId":null,"email":null,"exception":"[object] (ErrorException(code: 0): array_values() expects parameter 1 to be array, string given at /var/www/html/htdocs/content/plugins/visualizer/classes/Visualizer/Render/Layout.php:379) [stacktrace] #0 [internal function]: Themosis\\Core\\Bootstrap\\ExceptionHandler->handleError(2, 'array_values() ...', '/var/www/html/h...', 379, Array) #1 /var/www/html/htdocs/content/plugins/visualizer/classes/Visualizer/Render/Layout.php(379): array_values('https://docs.go...') #2 /var/www/html/htdocs/content/plugins/visualizer/classes/Visualizer/Render/Layout.php(48): Visualizer_Render_Layout::_renderEditorTable(Array) #3 /var/www/html/htdocs/content/plugins/visualizer/classes/Visualizer/Render/Layout.php(262): Visualizer_Render_Layout::show('editor-table', NULL, 70, 'viz-html-table', true, true) #4 /var/www/html/htdocs/content/plugins/visualizer/classes/Visualizer/Render/Layout.php(48): Visualizer_Render_Layout::_renderSimpleEditorScreen(Array) #5 /var/www/html/htdocs/content/plugins/visualizer/classes/Visualizer/Render/Page/Data.php(48): Visualizer_Render_Layout::show('simple-editor-s...', 70) #6 /var/www/html/htdocs/content/plugins/visualizer/classes/Visualizer/Render/Page.php(41): Visualizer_Render_Page_Data->_renderContent() #7 /var/www/html/htdocs/content/plugins/visualizer/classes/Visualizer/Render.php(151): Visualizer_Render_Page->_toHTML() #8 /var/www/html/htdocs/cms/wp-admin/includes/media.php(569): Visualizer_Render->render() #9 /var/www/html/htdocs/content/plugins/visualizer/classes/Visualizer/Module/Chart.php(712): wp_iframe(Array) #10 /var/www/html/htdocs/content/plugins/visualizer/classes/Visualizer/Module/Chart.php(515): Visualizer_Module_Chart->_handleDataAndSettingsPage() #11 /var/www/html/htdocs/cms/wp-includes/class-wp-hook.php(286): Visualizer_Module_Chart->renderChartPages('') #12 /var/www/html/htdocs/cms/wp-includes/class-wp-hook.php(310): WP_Hook->apply_filters('', Array) #13 /var/www/html/htdocs/cms/wp-includes/plugin.php(465): WP_Hook->do_action(Array) #14 /var/www/html/htdocs/cms/wp-admin/admin-ajax.php(173): do_action('wp_ajax_visuali...') #15 {main} "}This :
Render/Layout.php(379): array_values('https://docs.go...')is strange@tipytv I assume you are using the import data from URL feature. I have tried with the URL and it works perfectly. Can you please share a screen recording or reproduce this on a public instance where we can sort this out for you?
I’ll see may be tomorrow if i have time to reproduce it on a public instance.
I’ve made some tests, seems like this issue occurs when populating data for a datatables.
For a line chart, when i edit it,
$datais formatted like this :Array ( [source] => https://docs.google.com/spreadsheets/d/e/2PACX-1vQSolcWM_lQ0oHbNp_y-7PvG8WZtB2p3bh62lhXKqN9SYO9nlD3D9LRHUDF1ZPiKDbjVn_OX_yeCnkt/pub?gid=0&single=true&output=csv [data] => Array ( [0] => Array ( [0] => 03/08/2019 [1] => 3000 ) [1] => Array ( [0] => 04/08/2019 [1] => 3100 ) ...So here we must get data with
$data['data'].
If i make a datatables and try to edit it, this time$datais formatted as below :Array ( [0] => Array ( [0] => 2004/05/01 [1] => 165 [2] => 938 [3] => 522 [4] => 998 [5] => 450 ) [1] => Array ( [0] => 2005/06/01 [1] => 135 [2] => 1120 [3] => 599 [4] => 1268 [5] => 288 ) ...For each chart, when i edit it, this method
_renderEditorTableis always called onLayout.phpwith this foreach :foreach ($data as $row) { echo '<tr>'; echo '<th>' . __('Value', 'visualizer') . '</th>'; $index = 0; foreach (array_values($row) as $value) { if ($editable_data) { echo '<td><input type="text" name="data' . $index++ . '[]" value="' . esc_attr($value) . '"></td>'; } else { echo '<td>' . $value . '</td>'; } } echo '</tr>'; }But
$datawill not be the same, in the case of a line chart,array_values()trigger an error because on the first iteration,$rowis the value of$data['source'].I hope i’m clear enough, is this normal thah
_renderEditorTablis triggered when editing a line chart ?Tried to fit a datatables with the same source URL, also get
$datawith two keys,source(containing the URL), and thedata(containing all data).@tipytv as mentioned earlier can you please share a screen recording so we know what you are trying to do?
@tipytv I’m closing this for lack of response. If you continue to face this problem, please create a new ticket.
The topic ‘Issue while importing data from Google Spreadsheet’ is closed to new replies.