KoolReport's Forum

Official Support Area, Q&As, Discussions, Suggestions and Bug reports.
Forum's Guidelines

ChartTable how to onload to generate the chart #2266

Open kenny opened this topic on on Aug 17, 2021 - 4 comments

kenny commented on Aug 17, 2021

how to onload to generate the chart without press the generate button

Sebastian Morales commented on Aug 17, 2021

You could use the following js method to generate charttable's chart:

<script>
    myChartTable.generateChart(); // "myChartTable" is ChartTable php widget's name/id
</script>

Of course a label column and some data columns must be selected first for the chart to be generated correctly. You could also set those columns' selected values like this:

    $(myChartTable.labelColumnSel).val( [ "myLabelColumn" ] );
    $(myChartTable.dataColumnsSel).val( [ "myDataColumn1", "myDataColumn2" ] );
    ...
    myChartTable.generateChart(); // "myChartTable" is ChartTable php widget's name/id
kenny commented on Aug 17, 2021

default select time label column and select all data column

kenny commented on Aug 17, 2021

can u explain in detail ? like: which file to change it thankyou

Sebastian Morales commented on Aug 18, 2021

Just put the code in my previous code in your report view file where ChartTable widget is:

ChartTable::create(array(
    "name" => "myChartTable",
    ...
    "onReady" => "autoGenerateChart",
));
<script>
    function autoGenerateChart() {
        $(myChartTable.labelColumnSel).val( [ "myLabelColumn" ] ); // change this to your label column name
        $(myChartTable.dataColumnsSel).val( [ "myDataColumn1", "myDataColumn2" ] ); // change these to all of your data column names       
        myChartTable.generateChart(); // "myChartTable" is ChartTable php widget's name/id
    }
</script>

Build Your Excellent Data Report

Let KoolReport help you to make great reports. It's free & open-source released under MIT license.

Download KoolReport View demo
help needed

None