GriefCode Posted February 21, 2017 Posted February 21, 2017 Hey, I have included the class in the title in my code. However, the filters appear not to work with ajax calles. They are always rendering a new page, probably then the chart without any header as it also sets 'noHeader=1'. My Code: /** * @return void */ protected function manage() { $chart = new \IPS\sharedstats\DbIntegration\DynamicChart( \IPS\Http\Url::internal( 'app=sharedstats&module=stats&controller=dashboard' ), 'stats_games', 'datetime', '', array( 'isStacked' => TRUE ), 'LineChart', 'daily' ); $chart->addSeries( \IPS\Member::loggedIn()->language()->addToStack('games'), 'number', 'COUNT(*)' ); $chart->addSeries( \IPS\Member::loggedIn()->language()->addToStack('players'), 'number', '(COUNT(*) * 10)' ); $chart->title = \IPS\Member::loggedIn()->language()->addToStack('Player Stats'); $chart->availableTypes = array( 'LineChart', 'ColumnChart', 'BarChart' ); /* Display */ \IPS\Output::i()->title = \IPS\Member::loggedIn()->language()->addToStack( 'sharedstats_stats_dashboard' ); \IPS\Output::i()->breadcrumb[] = array( NULL, \IPS\Output::i()->title ); \IPS\Output::i()->output = \IPS\Theme::i()->getTemplate('stats', 'sharedstats', 'front')->dashboard($chart); } I have used my own class as that i need to connect to a remote database. It just changed the database access. When i call the page it does look like this: Once i change a filter to as example 'weekly', i got this: I used the same code as on messenger stats on ACP and there it does work. Did I miss something out? Do I need to include any JS file? Regards
bfarber Posted February 21, 2017 Posted February 21, 2017 Are you seeing any javascript errors in your browser console?
GriefCode Posted February 21, 2017 Author Posted February 21, 2017 Nope. You could check it out here:https://dota.vision/sharedStats/dashboard Only warnings due to mixed content. maybe thats caused it. Will check furthere.
Daniel F Posted February 21, 2017 Posted February 21, 2017 You can't use /* Display */ \IPS\Output::i()->title = \IPS\Member::loggedIn()->language()->addToStack( 'sharedstats_stats_dashboard' ); \IPS\Output::i()->breadcrumb[] = array( NULL, \IPS\Output::i()->title ); \IPS\Output::i()->output = \IPS\Theme::i()->getTemplate('stats', 'sharedstats', 'front')->dashboard($chart); for the ajax output Try something like if ( \IPS\Request::i()->noheader) { \IPS\Output::i()->output = $chart; } else { /* Display */ \IPS\Output::i()->title = \IPS\Member::loggedIn()->language()->addToStack( 'sharedstats_stats_dashboard' ); \IPS\Output::i()->breadcrumb[] = array( NULL, \IPS\Output::i()->title ); \IPS\Output::i()->output = \IPS\Theme::i()->getTemplate('stats', 'sharedstats', 'front')->dashboard($chart); } so that only the chart is returned if it is a ajax request.
GriefCode Posted February 21, 2017 Author Posted February 21, 2017 4 minutes ago, Daniel F said: You can't use /* Display */ \IPS\Output::i()->title = \IPS\Member::loggedIn()->language()->addToStack( 'sharedstats_stats_dashboard' ); \IPS\Output::i()->breadcrumb[] = array( NULL, \IPS\Output::i()->title ); \IPS\Output::i()->output = \IPS\Theme::i()->getTemplate('stats', 'sharedstats', 'front')->dashboard($chart); for the ajax output Try something like if ( \IPS\Request::i()->noheader) { \IPS\Output::i()->output = $chart; } else { /* Display */ \IPS\Output::i()->title = \IPS\Member::loggedIn()->language()->addToStack( 'sharedstats_stats_dashboard' ); \IPS\Output::i()->breadcrumb[] = array( NULL, \IPS\Output::i()->title ); \IPS\Output::i()->output = \IPS\Theme::i()->getTemplate('stats', 'sharedstats', 'front')->dashboard($chart); } Well you are right, but in fact it does still not load over ajax. Changing that will only show the chart itself and nothing else, that is final for the replacing later. It would have brought up another issue, indeed The ajax call issue is also not related to the mixed content blocking. I've just tested that out, doesn't work eithere when it would be allowed.
HeadStand Posted February 22, 2017 Posted February 22, 2017 The Dynamic charts, if I recall correctly, were built into the ACP and are not available by default on the front end. In order to get this working you need to include the admin JS libraries in your controller, like this: \IPS\Output::i()->jsFiles = array_merge( \IPS\Output::i()->jsFiles, \IPS\Output::i()->js( 'admin.js', 'global' ) ); You also should be sending back the chart (and only the chart) when the call is ajax, like this: if( \IPS\Request::i()->isAjax() ) { \IPS\Output::i()->output = (string)$chart; return; }
Recommended Posts
Archived
This topic is now archived and is closed to further replies.