File: /home/cafsindia/lifemaze_in/js/lp_snap.js
(function($){
$(function(){
M.AutoInit();
$('.sidenav').sidenav();
$('.carousel').carousel({
indicators: true
});
});
})(jQuery);
$(document).ready(function() {
overall_snap();
protection_snap();
goal_snap();
});
//PIE CHART COMMON SETTING
function get_pie_chart_option(render_to,title,legend){
return options = {
chart: {
type: 'pie',
renderTo: render_to,
},
plotOptions: {
pie: {
center: ["35%", "50%"],
allowPointSelect: true,
cursor: 'pointer',
dataLabels: {
enabled: true,
formatter: function() {
shortText = this.point.name;
if(this.point.name.length >= 7){
//shortText = jQuery.trim(this.point.name).substring(0,15)+"...";
}
return shortText;
}
},
showInLegend: legend
}
},
title: {
text: title
},
legend: {
enabled: true,
floating: true,
verticalAlign: 'bottom',
align:'right',
width:230,
x:0,
y:0,
useHTML: true,
labelFormatter: function() {
percentage = this.percentage.toFixed(2);
return "<div class='col-md-12 pd0' style='display:inline-flex;font-size:11px !important;border:1px dotted #CCCCCC;border-bottom:0px; font-weight: 400 !important;'><div style='float:left;width:65px;padding:2px;overflow:hidden; text-overflow:ellipsis;border-right: 1px dotted #CCCCCC;'>"+this.name+"</div><div style='float:left;padding:2px;width:75px;text-align:center;border-right: 1px dotted #CCCCCC;'>"+ this.y +"</div><div style='float:left;padding:2px;width:43px;'>"+percentage+"%</div></div>";
}
},
lang: {
drillUpText: '<< Back to top'
},
series: [],
drilldown: {
series: []
}
};
}
function get_line_colume_chart_option(chart_type,render_to){
return options = {
chart: {
type: chart_type,
renderTo: render_to,
},
title: {
text: ''
},
yAxis: {
min: 0,
title: {
text: ''
}
},
tooltip: {
headerFormat: '<span style="font-size:10px">{point.key}</span><table>',
pointFormat: '<tr><td style="color:{series.color};padding:0">{series.name}: </td>' +
'<td style="padding:0"><b>{point.y:.1f}</b></td></tr>',
footerFormat: '</table>',
shared: true,
useHTML: true
},
plotOptions: {
column: {
pointPadding: 0.2,
borderWidth: 0
},
pie: {
center: ["30%", "50%"],
allowPointSelect: true,
cursor: 'pointer',
dataLabels: {
enabled: true,
formatter: function() {
shortText = this.point.name;
if(this.point.name.length >= 7){
shortText = jQuery.trim(this.point.name).substring(0,6)+"...";
}
return shortText;
}
},
//showInLegend: false
}
},
/*
legend: {
enabled: false
},
*/
xAxis: {
categories: [],
crosshair: true
},
series: [],
drilldown: {
series: []
}
};
}
function overall_snap(){
var frm = "overall_snap";
$.ajax({
type: "POST",
url: "./bend/snap_callback",
data:{frm:frm},
success: function(data) {
var rslt = JSON.parse(data);
if(rslt.info === "Required Login"){
//send_login();
return false;
}
options = get_pie_chart_option("overall_snap",'Yearly Income vs Expence',true);
options.series = rslt.series;
options.drilldown.series = rslt.drill_list;
chart = new Highcharts.Chart(options);
window.dispatchEvent(new Event('resize'));
$("#overall_snap_tbl").html(rslt.table_info);
},
});
}
function protection_snap(){
var frm = "protection_snap";
$.ajax({
type: "POST",
url: "./bend/snap_callback",
data:{frm:frm},
success: function(data) {
var rslt = JSON.parse(data);
$("#profolio_tbl").html(rslt.profolio);
$("#sugg_derive_tbl").html(rslt.sugg_derive);
$("#health_tbl").html(rslt.health);
$('.modal').modal();
options = get_line_colume_chart_option("spline","pro_chart");
options.series = rslt.pro_list;
options.xAxis.categories = rslt.pro_cat;
chart = new Highcharts.Chart(options);
window.dispatchEvent(new Event('resize'));
options = get_line_colume_chart_option("column","hel_chart");
options.series = rslt.hel_list;
options.xAxis.categories = rslt.hel_cat;
chart = new Highcharts.Chart(options);
window.dispatchEvent(new Event('resize'));
},
});
}
function goal_snap(){
var frm = "goal_snap";
$.ajax({
type: "POST",
url: "./bend/snap_callback",
data:{frm:frm},
success: function(data) {
var rslt = JSON.parse(data);
options = get_line_colume_chart_option("column","goal_snap");
options.series = rslt.series;
options.xAxis.categories = rslt.categories;
chart = new Highcharts.Chart(options);
window.dispatchEvent(new Event('resize'));
$("#goal_snap_tbl").html(rslt.table_info);
},
});
}