I have a problem with full calendar, it's not showing the description i dont know why.. my code is:
$('#calendar').fullCalendar({
header: {
left: 'prev,next today',
center: 'title',
right: 'month,agendaWeek,agendaDay'
},
buttonText: {
today: 'hoy',
month: 'mes',
week: 'semana',
day: 'día'
},
//Random default events
events: function(start, end, timezone, callback) {
$.ajax({
url: "<?php echo base_url(); ?>calendar/retrieve",
type: 'POST',
dataType: 'html',
data: {
start: start.format(),
end: end.format()
},
success: function(doc)
{
var events = [];
var eventRender = [];
if(!doc.result)
{
$.each($.parseJSON(doc), function() {
events.push({
title: this.description,
start: this.start_date,
end: this.end_date,
backgroundColor: "#0073b7",
description: 'second description',
borderColor: "#0073b7"
});
});
}
callback(events);
}
});
},
I'm getting the information from a database and then I show it in the calendar... I put description: 'some description...', but when I see the calendar it is not displaying that, why? or if you know another way to put a description, a tooltip maybe i dunno... I have seen examples but without a loop and i need how to put with a loop..
I am using the fullcalendar version 3.4.0
Thanks!
You can try to change $.each loop like this:
$.each(JSON.stringify(doc), function (i, d) {
events.push({
title: doc[i].description,
start: doc[i].start_date,
end: doc[i].end_date,
backgroundColor: "#0073b7",
description: 'second description',
borderColor: "#0073b7"
});
});
I have the following data that I get dynamically from the mysql query via json and ajax. It just cant populate into the graph. I have shown below how my sample data looks likes. I put some sammple data into the data series as below. I also tried this chart.series[0].setData( eval( '(' + data + ')' ) ); not working either
["[1443843286000,0]",
"[1443843286000,100]",
"[1443843356000,200]",
"[1443843356000,0]",
"[1443843356000,100]",
"[1443843359000,0]"," ....
Here is the snippet of mysql how this data is generated.
while($row = $selectQueryResult1->fetch())
{
$count++;
$dateTimer1 =$row['dateTimer']*1000;
$speed=$row['speed'];
$data[] = "[$dateTimer1,$speed]";
}
echo json_encode($data);
Calling ajax and chart initialisation.
$(function () {
var chart;
$(document).ready(function() {
chart = new Highcharts.Chart({
chart: {
renderTo: 'dashBoardData',
type: 'line',
marginRight: 130,
marginBottom: 25
},
title: {
text: 'Speed Graph:' ,
x: -20 //center
},
subtitle: {
text: '',
x: -20
},
xAxis: {
type: 'datetime',
dateTimeLabelFormats: {
second: '%Y-%m-%d %H:%M',
minute: '%Y-%m-%d %H:%M',
hour: '%Y-%m-%d %H:%M',
day: '%Y-%m-%d %H:%M',
week: '%Y-%m-%d %H:%M',
month: '%Y-%m-%d %H:%M',
year: '%Y-%m-%d %H:%M'
},
title: {
text: 'Date Time'
},
labels: {
rotation: 0
}
},
yAxis: {
title: {
text: 'Speed (km/h)'
},
min: 0
},
tooltip: {
formatter: function() {
return '<b>'+ this.series.name +'</b><br/>'+
Highcharts.dateFormat('%Y-%m-%d %H:%M', this.x) +': '+ this.y;
}
},
legend: {
layout: 'vertical',
align: 'right',
verticalAlign: 'top',
x: -10,
y: 100,
borderWidth: 1
},
credits: {
enabled: false
},
series: [{
name: 'Speed Data'
}]
});
$("#SearchDb").click(function(){
var data = $(this).val();
var dateFrom=document.getElementById("beginDateInput").value;
dateTimeFromArray=dateFrom.split(" ");
dateFromArray=dateTimeFromArray[0].split("/");
var dateTo=document.getElementById("endDateInput").value;
dateTimeToArray=dateTo.split(" ");
dateToArray=dateTimeToArray[0].split("/");
mysqlDateFrom=dateFromArray[2]+"-"+dateFromArray[1]+"-"+dateFromArray[0]+" "+dateTimeFromArray[1];
mysqlDateTo=dateToArray[2]+"-"+dateToArray[1]+"-"+dateToArray[0]+" "+dateTimeToArray[1];
$.post('getSpeedGraph.php', {b: mysqlDateFrom,e:mysqlDateTo }, function(data){
chart.series[0].setData(["[1443843286000,0]","[1443843286000,100]","[1443843356000,200]","[1443843356000,0]","[1443843356000,100]","[1443843359000,0]","[1443843359000,0]","[1443843369000,0]","[1443843369000,0]","[1443843380000,0]","[1443843380000,0]","[1443843389000,0]","[1443843389000,0]","[1443843409000,0]","[1443843409000,0]","[1443843419000,0]","[1443843419000,0]","[1443843419000,0]","[1443843482000,0]","[1443843482000,0]","[1443843482000,0]","[1443843545000,17]","[1443843545000,20]","[1443843545000,20]","[1443843576000,0]","[1443843576000,0]","[1443843576000,0]","[1443843639000,7]","[1443843639000,7]","[1443843639000,6]","[1443843667000,0]","[1443843667000,0]","[1443843667000,0]","[1443843732000,0]","[1443843732000,0]","[1443843732000,0]","[1443843796000,0]","[1443843796000,0]","[1443843796000,0]","[1443843859000,0]","[1443843859000,0]","[1443843859000,0]","[1443843927000,0]","[1443843927000,0]","[1443843927000,0]","[1443843990000,0]","[1443843990000,0]","[1443843990000,0]","[1443844056000,0]","[1443844056000,0]","[1443844056000,0]","[1443844119000,0]","[1443844119000,0]","[1443844119000,0]","[1443844182000,0]","[1443844182000,0]","[1443844182000,0]","[1443844236000,0]","[1443844236000,0]","[1443844236000,0]","[1443844300000,0]","[1443844300000,0]","[1443844300000,0]","[1443844363000,0]","[1443844363000,0]","[1443844363000,0]","[1443844428000,0]","[1443844428000,0]","[1443844428000,0]","[1443844491000,0]","[1443844491000,0]","[1443844491000,0]","[1443844554000,0]","[1443844554000,0]","[1443844554000,0]","[1443844617000,0]","[1443844617000,0]","[1443844617000,0]","[1443844755000,0]","[1443844755000,0]","[1443844852000,0]","[1443844852000,0]","[1443844852000,0]","[1443844876000,0]","[1443844876000,0]","[1443844876000,0]","[1443844948000,0]","[1443844948000,0]","[1443844948000,0]","[1443845021000,0]","[1443845021000,0]","[1443845021000,0]","[1443845085000,10]","[1443845085000,10]","[1443845085000,9]","[1443845159000,0]","[1443845159000,0]","[1443845159000,0]","[1443845223000,0]","[1443845223000,0]","[1443845223000,0]","[1443845287000,0]","[1443845287000,0]","[1443845287000,0]","[1443845353000,0]","[1443845353000,0]","[1443845353000,0]","[1443845377000,13]","[1443845377000,12]","[1443845377000,11]","[1443845442000,0]","[1443845442000,0]","[1443845442000,2]","[1443845508000,0]","[1443845508000,0]","[1443845508000,0]","[1443845573000,0]"]);
}
);
}
);
});
});
I found the solution to a simple. Just for the help and reference of other just run this chart.series[0].setData( eval(data) );
i'm starting to learn PHP, JavaScript, JQuery...
I need to make a graph, and I'm going to use HighCharts. I have a form with 3 select and a button. When i push the button, I want to display the graph. The function to make the graph is on the examples, but I don't know if I need to put the function in another PHP file, or JavaScript file, how to call the function and how to pass parameters...
The code to make the graph is this:
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>
<script type="text/javascript">
$(function () {
var chart;
$(document).ready(function() {
chart = new Highcharts.Chart({
chart: {
renderTo: 'container',
type: 'bar'
},
title: {
text: 'Historic World Population by Region'
},
subtitle: {
text: 'Source: Wikipedia.org'
},
xAxis: {
categories: ['Africa', 'America', 'Asia', 'Europe', 'Oceania'],
title: {
text: null
}
},
yAxis: {
min: 0,
title: {
text: 'Population (millions)',
align: 'high'
},
labels: {
overflow: 'justify'
}
},
tooltip: {
formatter: function() {
return ''+
this.series.name +': '+ this.y +' millions';
}
},
plotOptions: {
bar: {
dataLabels: {
enabled: true
}
}
},
legend: {
layout: 'vertical',
align: 'right',
verticalAlign: 'top',
x: -100,
y: 100,
floating: true,
borderWidth: 1,
backgroundColor: '#FFFFFF',
shadow: true
},
credits: {
enabled: false
},
series: [{
name: 'Year 1800',
data: [107, 31, 635, 203, 2]
}, {
name: 'Year 1900',
data: [133, 156, 947, 408, 6]
}, {
name: 'Year 2008',
data: [973, 914, 4054, 732, 34]
}]
});
});
});
</script>
<script src="../../js/highcharts.js"></script>
<script src="../../js/modules/exporting.js"></script>
Since you're not depending on any ajax calls to your server you don't need to involve PHP at all yet. Once you need to communicate with a database or do other server-side processing, that'll be where you need PHP.
Just put that code into the body of an html file (eg index.html) and it should work fine.
I am loading data stored in a MySQL Database.
The chart doesn't show up on the webpage, but it doesn't show any other warning.
My PHP webpage returns a JSON encoded header with the following information:
["John Doe","2","Jane Doe","3"]
The script that loads the information is the following:
var chart;
function requestData() {
$.ajax({
url:'includes/bin/get_leaders.php',
success: function(point) {
alert(point);
var series = chart.series[0],
shift = series.data.length > 20; // shift if the series is longer than 20
chart.series[0].addPoint(point, true, shift);
},
cache: false
});
$(document).ready(function() {
chart = new Highcharts.Chart({
chart: {
renderTo: 'container',
type: 'bar',
events: {load: requestData}
},
title: {
text: 'Top Agents'
},
xAxis: {
type: 'int',
title: {text: null}
},
yAxis: {
min: 0,
title: { text: 'Sales this Week', align: 'low'}
},
tooltip: {
formatter: function() {
return ''+ this.series.name +': '+ this.y +' sales';
}
},
plotOptions: {
bar: {
dataLabels: {
enabled: true
}
}
},
legend: {
layout: 'vertical',
align: 'right',
verticalAlign: 'top',
x: -100,
y: 100,
floating: true,
borderWidth: 0,
backgroundColor: '#FFFFFF',
shadow: false
},
credits: {
enabled: false
},
series: [{
name: 'Sales' }]
});
});
});
Any clue what's going on?
Thank you!
Looks like you are passing in a ["string", "number", "string", "number"].
What you want is {2, 3} for your series and then for your xAxis to use a category list of {"John Doe", "Jane Doe"}.