How to make the date scrollbar start at a certain date
-
Hello, I currently have a graph with one of those sliders on the top which you can change the date you are looking at with.
Here is a picture of it.
The range of the graph is from the start of this year untill yesterday.
This all works properly and as intended.However, when I load the page it always starts with the entire range.
I would like the graph to load with the starting date being today -10 days untill today. But I would like the entire slider to still be from this entire year.Is this possible?
Here is my code if you need it:
var chart;
// create chart
AmCharts.ready(function() {
// load the data
var chartData = AmCharts.loadJSON(‘https://localhost/QMS/wordpress/data.php’);
// SERIAL CHART
chart = new AmCharts.AmSerialChart();
chart.dataProvider = chartData;
chart.categoryField = “WBD_DATUM”;
chart.dataDateFormat = “DD-MM-YY”;
// GRAPHS
var graph1 = new AmCharts.AmGraph();
graph1.valueField = “WBD_BEREKENDE_WAARDE”;
graph1.bulletBorderThickness = 2;
graph1.lineThickness = 2;
graph1.lineAlpha = 0.5;
graph1.type = “line”;
graph1.columnWidth = “0”;
graph1.lineColor = “#4b1966”;
graph1.balloonText = “”;
graph1.gridColor = “#4b1966”;
chart.addGraph(graph1);
//ONDERGRENS
var graph2 = new AmCharts.AmGraph();
graph2.valueField = “MDL_ONDERGRENS”;
graph2.bulletBorderThickness = 2;
graph2.lineThickness = 2;
graph2.lineAlpha = 0.5;
graph2.type = “line”;
graph2.columnWidth = “0”;
graph2.lineColor = “#DB6767”;
graph2.balloonText = “”;
graph2.gridColor = “#4b1966”;
chart.addGraph(graph2);
// CATEGORY AXIS
chart.categoryAxis.parseDates = false;
//chart.categoryAxis.ignoreAxisWidth = false;
var valueAxis = new AmCharts.ValueAxis();
valueAxis.labelsEnabled = false;
chart.addValueAxis(valueAxis);chart.chartScrollbar = new AmCharts.ChartScrollbar();
chart.chartCursor = new AmCharts.ChartCursor();
chart.mouseWheelZoomEnabled = true;
chart.mouseWheelScrollEnabled = true;
// WRITE
chart.write(“chartdiv”);
});
AmCharts.loadJSON = function(url) {
// create the request
if (window.XMLHttpRequest) {
// IE7+, Firefox, Chrome, Opera, Safari
var request = new XMLHttpRequest();
} else {
// code for IE6, IE5
var request = new ActiveXObject(‘Microsoft.XMLHTTP’);;
}
// load it
// the last “false” parameter ensures that our code will wait before the
// data is loaded
request.open(‘GET’, url, false);
request.send();
// parse adn return the output
return eval(request.responseText);
};
- The topic ‘How to make the date scrollbar start at a certain date’ is closed to new replies.