$(function () { //------------- //- BAR CHART - //------------- var barChartCanvas = $('#barChart').get(0).getContext('2d'); var barChart = new Chart(barChartCanvas); var barChartData = areaChartData; barChartData.datasets[1].fillColor = '#00bbff'; barChartData.datasets[1].strokeColor = '#00bbff'; barChartData.datasets[1].pointColor = '#00bbff'; var barChartOptions = { //Boolean - Whether the scale should start at zero, or an order of magnitude down from the lowest value scaleBeginAtZero : true, //Boolean - Whether grid lines are shown across the chart scaleShowGridLines : true, //String - Colour of the grid lines scaleGridLineColor : 'rgba(0,0,0,.05)', //Number - Width of the grid lines scaleGridLineWidth : 1, //Boolean - Whether to show horizontal lines (except X axis) scaleShowHorizontalLines: true, //Boolean - Whether to show vertical lines (except Y axis) scaleShowVerticalLines : true, //Boolean - If there is a stroke on each bar barShowStroke : true, //Number - Pixel width of the bar stroke barStrokeWidth : 2, //Number - Spacing between each of the X value sets barValueSpacing : 5, //Number - Spacing between data sets within X values barDatasetSpacing : 1, //String - A legend template legendTemplate : '', //Boolean - whether to make the chart responsive responsive : true, maintainAspectRatio : true }; barChartOptions.datasetFill = false; barChart.Bar(barChartData, barChartOptions); //------------- //- PIE CHART - //------------- // Get context with jQuery - using jQuery's .get() method. var pieChartCanvas = $('#pieChart').get(0).getContext('2d'); var pieChart = new Chart(pieChartCanvas); var pieOptions = { //Boolean - Whether we should show a stroke on each segment segmentShowStroke : true, //String - The colour of each segment stroke segmentStrokeColor : '#fff', //Number - The width of each segment stroke segmentStrokeWidth : 2, //Number - The percentage of the chart that we cut out of the middle percentageInnerCutout: 50, // This is 0 for Pie charts //Number - Amount of animation steps animationSteps : 100, //String - Animation easing effect animationEasing : 'easeOutBounce', //Boolean - Whether we animate the rotation of the Doughnut animateRotate : true, //Boolean - Whether we animate scaling the Doughnut from the centre animateScale : false, //Boolean - whether to make the chart responsive to window resizing responsive : true, // Boolean - whether to maintain the starting aspect ratio or not when responsive, if set to false, will take up entire container maintainAspectRatio : true, //String - A legend template legendTemplate : '' }; //Create pie or douhnut chart // You can switch between pie and douhnut using the method below. pieChart.Doughnut(Pie, pieOptions); //------------- //- PIE CHART - //------------- // Get context with jQuery - using jQuery's .get() method. var pieChartCanvas2 = $('#pieChart2').get(0).getContext('2d'); var pieChart2 = new Chart(pieChartCanvas2); var pieOptions2 = { //Boolean - Whether we should show a stroke on each segment segmentShowStroke : true, //String - The colour of each segment stroke segmentStrokeColor : '#fff', //Number - The width of each segment stroke segmentStrokeWidth : 2, //Number - The percentage of the chart that we cut out of the middle percentageInnerCutout: 50, // This is 0 for Pie charts //Number - Amount of animation steps animationSteps : 100, //String - Animation easing effect animationEasing : 'easeOutBounce', //Boolean - Whether we animate the rotation of the Doughnut animateRotate : true, //Boolean - Whether we animate scaling the Doughnut from the centre animateScale : false, //Boolean - whether to make the chart responsive to window resizing responsive : true, // Boolean - whether to maintain the starting aspect ratio or not when responsive, if set to false, will take up entire container maintainAspectRatio : true, //String - A legend template legendTemplate : '' }; //Create pie or douhnut chart // You can switch between pie and douhnut using the method below. pieChart2.Doughnut(Pie2, pieOptions2); console.log(geocodeposition(52.5487429714954,-1.81602098644987)); }); function geocodeposition(lat, lng){ var city; var url = "https://nominatim.openstreetmap.org/reverse?format=json&lat="+lat+"&lon="+lng+"&zoom=18&addressdetails=1"; $.getJSON(url, function( data ) { //console.log(data.address.city); city = data.address.city; }); return city; }