• Resolved tipytv

    (@tipytv)


    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)

Viewing 11 replies - 1 through 11 (of 11 total)
  • Plugin Contributor contactashish13

    (@rozroz)

    @tipytv can you please provide the URL so that we can try to reproduce the issue at our end?

    Thread Starter tipytv

    (@tipytv)

    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:csv

    Plugin Contributor contactashish13

    (@rozroz)

    @tipytv this CSV does not seem to be in the format expected by the plugin. The second row that specifies the data type is missing. You can refer to our sample CSVs by clicking on the link shown here

    Thread Starter tipytv

    (@tipytv)

    I’ve added the second line with data types, but the issue remain the same.
    Can you try again with the same url ?

    Plugin Contributor contactashish13

    (@rozroz)

    @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.

    Thread Starter tipytv

    (@tipytv)

    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=csv

    It 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

    Plugin Contributor contactashish13

    (@rozroz)

    @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?

    Thread Starter tipytv

    (@tipytv)

    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, $data is 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 $data is 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 _renderEditorTable is always called on Layout.php with 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 $data will not be the same, in the case of a line chart, array_values() trigger an error because on the first iteration, $row is the value of $data['source'].

    I hope i’m clear enough, is this normal thah _renderEditorTabl is triggered when editing a line chart ?

    Thread Starter tipytv

    (@tipytv)

    Tried to fit a datatables with the same source URL, also get $data with two keys, source (containing the URL), and the data (containing all data).

    Plugin Contributor contactashish13

    (@rozroz)

    @tipytv as mentioned earlier can you please share a screen recording so we know what you are trying to do?

    Plugin Contributor contactashish13

    (@rozroz)

    @tipytv I’m closing this for lack of response. If you continue to face this problem, please create a new ticket.

Viewing 11 replies - 1 through 11 (of 11 total)
  • The topic ‘Issue while importing data from Google Spreadsheet’ is closed to new replies.