TechAttax Posted January 6, 2016 Report Share Posted January 6, 2016 Does anybody know how to replace the default charts with these ones I found on the internet called Charts.js and can be downloaded here. 1 Quote Link to comment Share on other sites More sharing options...
ctabuyo Posted January 6, 2016 Report Share Posted January 6, 2016 If I don´t remember bad, I read a post from Nabeel that stated that the charts were hard-coded and there was no way to change them. Quote Link to comment Share on other sites More sharing options...
web541 Posted January 7, 2016 Report Share Posted January 7, 2016 I've never done it using Charts.js, but I've used Morris Charts before. - You could probably tweak it for charts.js What I did was put the following in core/modules/Pilots/Pilots.php public function morrisstatsbymonthdata() { $data = PIREPData::getIntervalDataByMonth(array('p.pilotid'=>Auth::$userinfo->pilotid), 3); header("Content-type: application/json"); echo json_encode($data); } public function morrisstatsaircraftdata($pilotid) { $data = StatsData::PilotAircraftFlownCountsMorris($pilotid); header("Content-type: application/json"); echo json_encode($data); } core/common/StatsData.class.php public static function PilotAircraftFlownCountsMorris($pilotid) { $key = 'ac_flown_counts_1_'.$pilotid; $counts = CodonCache::delete($key); if($counts === true) { //Select aircraft types $sql = 'SELECT a.name AS label, COUNT(p.aircraft) AS value, SUM(p.flighttime) AS hours FROM '.TABLE_PREFIX.'pireps p, '.TABLE_PREFIX.'aircraft a WHERE p.aircraft = a.id AND p.pilotid='.intval($pilotid).' GROUP BY a.name'; $counts = DB::get_results($sql); CodonCache::write($key, $counts, 'medium'); } return $counts; } If your using phpvms 5.5.x core/common/StatsData.class.php public static function PilotAircraftFlownCountsMorris($pilotid) { $key = 'ac_flown_counts_1_'.$pilotid; $counts = CodonCache::delete($key); if($counts === false) { //Select aircraft types $sql = 'SELECT a.name AS label, COUNT(p.aircraft) AS value, SUM(p.flighttime) AS hours FROM '.TABLE_PREFIX.'pireps p, '.TABLE_PREFIX.'aircraft a WHERE p.aircraft = a.id AND p.pilotid='.intval($pilotid).' GROUP BY a.name'; $counts = DB::get_results($sql); CodonCache::write($key, $counts, 'medium'); } return $counts; } And here's my core/templates/profile_stats.tpl/php (should really be in lib/skins/XXX/profile_stats.tpl/php) <link rel="stylesheet" href="//cdnjs.cloudflare.com/ajax/libs/morris.js/0.5.1/morris.css"> <script src="//ajax.googleapis.com/ajax/libs/jquery/1.9.0/jquery.min.js"></script> <script src="//cdnjs.cloudflare.com/ajax/libs/raphael/2.1.0/raphael-min.js"></script> <script src="//cdnjs.cloudflare.com/ajax/libs/morris.js/0.5.1/morris.min.js"></script> <h3>Your Stats</h3> <?php /* Added in 2.0! */ $chart_width = '800'; $chart_height = '250'; /* Don Not need to change anything below this here */ ?> <div align="center" style="width: 100%;"> <div id="monthdata" style="height: 250px;"></div> </div> <br /> <div align="center" style="width: 100%;"> <div id="aircraftdata" style="height: 250px;"></div> </div> <script type="text/javascript"> var json = (function () { var json = null; $.ajax({ 'async': false, 'global': false, 'url': "<?php echo actionurl('/pilots/morrisstatsbymonthdata');?>", 'dataType': "json", 'success': function (data) { json = data; } }); return json; }) (); new Morris.Line({ // ID of the element in which to draw the chart. element: 'monthdata', // Chart data records -- each entry in this array corresponds to a point on // the chart. data: json, // The name of the data record attribute that contains x-values. xkey: 'ym', // A list of names of data record attributes that contain y-values. ykeys: ['total'], // Labels for the ykeys -- will be displayed when you hover over the // chart. labels: ['Flights'] }); </script> <script type="text/javascript"> var json = (function () { var json = null; $.ajax({ 'async': false, 'global': false, 'url': "<?php echo actionurl('/pilots/morrisstatsaircraftdata/'.Auth::$userinfo->pilotid.'');?>", 'dataType': "json", 'success': function (data) { json = data; } }); return json; }) (); Morris.Donut({ element: 'aircraftdata', data: json }); </script> The end result http://imgur.com/wyb2lUz Thanks to Vangelis for providing most of the base code. 1 Quote Link to comment Share on other sites More sharing options...
RuiMiguel Posted January 7, 2016 Report Share Posted January 7, 2016 Thanks web541 just a question it is possible to create the pirep view report ? see exemple Thanks Quote Link to comment Share on other sites More sharing options...
web541 Posted January 7, 2016 Report Share Posted January 7, 2016 Where would you find that map? (Vataware?) Quote Link to comment Share on other sites More sharing options...
TechAttax Posted January 7, 2016 Author Report Share Posted January 7, 2016 @web541 After trying that I get this error Parse error: syntax error, unexpected 'public' (T_PUBLIC) in /home/techattax/public_html/airline/core/modules/Pilots/Pilots.php on line 123 Quote Link to comment Share on other sites More sharing options...
web541 Posted January 7, 2016 Report Share Posted January 7, 2016 What version of phpVMS are you using? And what's line 123 for you? Quote Link to comment Share on other sites More sharing options...
TechAttax Posted January 7, 2016 Author Report Share Posted January 7, 2016 What version of phpVMS are you using? And what's line 123 for you? I am using the latest phpVMS and line 123 has the code I copied from above. Quote Link to comment Share on other sites More sharing options...
web541 Posted January 7, 2016 Report Share Posted January 7, 2016 Try copying it to the end of the file before the last } Quote Link to comment Share on other sites More sharing options...
TechAttax Posted January 7, 2016 Author Report Share Posted January 7, 2016 Try copying it to the end of the file before the last } Thank you very much got it working now! Quote Link to comment Share on other sites More sharing options...
web541 Posted January 7, 2016 Report Share Posted January 7, 2016 np Glad to help Quote Link to comment Share on other sites More sharing options...
RuiMiguel Posted January 8, 2016 Report Share Posted January 8, 2016 yes in vateware Quote Link to comment Share on other sites More sharing options...
web541 Posted January 8, 2016 Report Share Posted January 8, 2016 Correct me if I'm wrong, but I don't think phpVMS stores all that information in the database. So I don't think that map is possible. Quote Link to comment Share on other sites More sharing options...
RuiMiguel Posted January 8, 2016 Report Share Posted January 8, 2016 you are right ,but I have Flight Position Tracker Quote Link to comment Share on other sites More sharing options...
web541 Posted January 8, 2016 Report Share Posted January 8, 2016 As I do not own that module, I can't help you, however if it records the positions in your database then it is probably possible in some way, shape or form. Quote Link to comment Share on other sites More sharing options...
RuiMiguel Posted January 8, 2016 Report Share Posted January 8, 2016 if you want I can send by mail Quote Link to comment Share on other sites More sharing options...
Moderators shakamonkey88 Posted February 13, 2018 Moderators Report Share Posted February 13, 2018 Hey all, For some reason, I couldn't get the PIREP chart to show. The aircraft one works perfectly, but not the PIREP line graph. Going to /action.php/pilots/morrisstatsbymonthdata does not show populated JSON data either. I am on phpvms 5.5.2 on php5.6 Edit: Ignore. It was because I was running it on a local copy of my site and the database is older than a month, hence no data for the last month! Duh... Quote Link to comment Share on other sites More sharing options...
ncd200 Posted January 9, 2020 Report Share Posted January 9, 2020 Sorry to open an old topic, but is it also possible to show this on the public profile? It is showing but on all the pilots the same numbers Quote Link to comment Share on other sites More sharing options...
web541 Posted January 9, 2020 Report Share Posted January 9, 2020 8 hours ago, ncd200 said: Sorry to open an old topic, but is it also possible to show this on the public profile? It is showing but on all the pilots the same numbers Which graph are you looking to get? For the donut, you would have to change this 'url': "<?php echo actionurl('/pilots/morrisstatsaircraftdata/'.Auth::$userinfo->pilotid.'');?>", to this 'url': "<?php echo actionurl('/pilots/morrisstatsaircraftdata/'.$pilot->pilotid.'');?>", And similarly, for the monthly chart, you would have to replace this public function morrisstatsbymonthdata() { $data = PIREPData::getIntervalDataByMonth(array('p.pilotid'=>Auth::$userinfo->pilotid), 3); header("Content-type: application/json"); echo json_encode($data); } with this public function morrisstatsbymonthdata($pilotid) { $data = PIREPData::getIntervalDataByMonth(array('p.pilotid'=> DB::escape($pilotid)), 3); header("Content-type: application/json"); echo json_encode($data); } And this $.ajax({ 'async': false, 'global': false, 'url': "<?php echo actionurl('/pilots/morrisstatsbymonthdata');?>", 'dataType': "json", 'success': function(data) { json = data; } }); return json; Replace with this $.ajax({ 'async': false, 'global': false, 'url': "<?php echo actionurl('/pilots/morrisstatsbymonthdata/'.$pilot->pilotid.'');?>", 'dataType': "json", 'success': function(data) { json = data; } }); return json; and I would think that would work. Quote Link to comment Share on other sites More sharing options...
ncd200 Posted January 13, 2020 Report Share Posted January 13, 2020 thanks, will try this when our new domain is set up much appreciated! Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.