I am facing issue while implementing 'ChartRangeFilter' control in google charts which uses date field as a Range filter. I am fetching data from MySQL database using JSON approach (JSON encoded data) and using it in view to render Line Chart in my Laravel application.
If I use Date field as String data type then it works but then I can not implement 'ChartRangeFilter' as it only works with number and data type fields and due to this I have hard-coded whole data in my view with Date constructor. e.g.new Date(Year, Month, Day).
But hard-coding data is not feasible solution hence is there any alternative solution available in which I can use JSON encoded date field in 'ChartRangeFilter'in google charts?
Here is my code snippet along with table schema.
function drawChart() {
var jsonData = $.ajax({
url: 'get_tests',
contentType: 'application/json',
dataType: 'json',
async: false
}).responseText;
var data = new google.visualization.DataTable(jQuery.parseJSON(jsonData));
// var data = new google.visualization.DataTable(obj);
// create chart
var chart = new google.visualization.LineChart(document.getElementById('chart_div'));
chart.draw(data);
}
Data-table Schema:
Column label Format
Datetime date
Buy number
Sell number