Hi,
I'm looking for a simple solution to display a bar chart with the data from the actual table view under the table in table view.
E.g. I have fields for status. The choice is high, medium, low. Now I just want a chart under the table that shows how many entries each with high, medium, low are displayed in the table.
Which tool is best suited for this? Chart.js? Or is that already possible with the AppGini Summary Reports plugin?
I would be very happy about an example if someone has already done it this way.
Thank you very much!
Chart under table in table view
Re: Chart under table in table view
Hi,
using chartist you can have a simple example like:
in your hooks / TABLENAME.php -> TABLENAME_header function try this:
You need to play around with the different options, like colors etc. But I leave that up to you
using chartist you can have a simple example like:
in your hooks / TABLENAME.php -> TABLENAME_header function try this:
Code: Select all
case 'tableview':
$sql="SELECT FIELDSTATUS, count(FIELDSTATUS) FROM `TABLENAME` group by FIELDSTATUS";
$res=sql($sql,$eo);
while ($row=db_fetch_row($res)) {
$data[$row[0]]=$row[1];
}
$header='<%%HEADER%%><link rel="stylesheet" href="//cdn.jsdelivr.net/chartist.js/latest/chartist.min.css"><script src="https://cdnjs.cloudflare.com/ajax/libs/chartist/0.11.4/chartist.min.js"></script><script>
$j(function() {
var cn=\'<div class="ct-chart ct-perfect-fourth"></div>\';
$j(".table-responsive").append(cn);
new Chartist.Bar(\'.ct-chart\',
{
labels: [\''.implode("','",array_keys($data)).'\'],
series: [['.implode(",",array_values($data)).']]
},
{
width: 800, // <-- adjust your settings
height: 300
}
);
});
</script>';
Any help offered comes with the best of intentions. Use it at your own risk. In any case, please make a backup of your existing environment before applying any changes.
Re: Chart under table in table view
Thank you very much! I will try it
Many greetings, Kai
Many greetings, Kai
Re: Chart under table in table view
i got it 1000 x thanks! I've been trying for days but can't get it by myself.
Re: Chart under table in table view
The chart shows the result of all data sets. Can I also limit the chart to the filtered view?
Re: Chart under table in table view
Sure,
just add a where clause in the SQL statement
SELECT FIELDSTATUS, count(FIELDSTATUS) FROM `TABLENAME` WHERE WHERECLAUSE group by FIELDSTATUS
You need to check what the parameters are $_REQUEST will show them. Also you might need to know how many records are shown, if you want to display the graph to the amount of records shown in the TV. But this you need to know and hard code as there is no variable to my knowledge that you might access.
just add a where clause in the SQL statement
SELECT FIELDSTATUS, count(FIELDSTATUS) FROM `TABLENAME` WHERE WHERECLAUSE group by FIELDSTATUS
You need to check what the parameters are $_REQUEST will show them. Also you might need to know how many records are shown, if you want to display the graph to the amount of records shown in the TV. But this you need to know and hard code as there is no variable to my knowledge that you might access.
Any help offered comes with the best of intentions. Use it at your own risk. In any case, please make a backup of your existing environment before applying any changes.
Re: Chart under table in table view
How am I supposed to do that?
I.E. if someone uses the quick search field to filter, I don't know how many records the result is.
Or have I thought incorrectly about that?
I.E. if someone uses the quick search field to filter, I don't know how many records the result is.
Or have I thought incorrectly about that?
Re: Chart under table in table view
One problem more with that
I need to select only records from actual logged in member. The chart shows the result from all records in database.
I need to select only records from actual logged in member. The chart shows the result from all records in database.
Re: Chart under table in table view
Hi,
well all this needs to be handled with the SQL query (the sample was just high level). You need to set-up the query to your needs.
The $_REQUEST array gives you all the needed data for the request itself, like filter, searchstring, catch the memberinfo via the getMemberInfo call.
well all this needs to be handled with the SQL query (the sample was just high level). You need to set-up the query to your needs.
The $_REQUEST array gives you all the needed data for the request itself, like filter, searchstring, catch the memberinfo via the getMemberInfo call.
Any help offered comes with the best of intentions. Use it at your own risk. In any case, please make a backup of your existing environment before applying any changes.
Re: Chart under table in table view
Thank you very much. I will try to find out the $_REQUEST parameters.
Re: Chart under table in table view
Unfortunately I can't do it. I've been trying all day. With your code I get the chart evaluation of all data sets. This works well.
But i need the counts from the current view not all records in database.
I don't know what kind of $_REQUEST parameter I need and unfortunately also not how to build it into the SQL select
But i need the counts from the current view not all records in database.
I don't know what kind of $_REQUEST parameter I need and unfortunately also not how to build it into the SQL select
Re: Chart under table in table view
Hi,
as this depends completely on your app it is not possible to provide more than the generic help here. If you need further coding support, please look for a coder to help you.
as this depends completely on your app it is not possible to provide more than the generic help here. If you need further coding support, please look for a coder to help you.
Any help offered comes with the best of intentions. Use it at your own risk. In any case, please make a backup of your existing environment before applying any changes.
Re: Chart under table in table view
Ok, and thanks much for your help!