mirror of
https://github.com/pi-hole/web.git
synced 2025-12-25 05:05:33 +00:00
Starting the Long-term graph on the the earliest date contained in the database.
Signed-off-by: rdwebdesign <github@rdwebdesign.com.br>
This commit is contained in:
@@ -15,6 +15,15 @@ var interval = 0;
|
||||
|
||||
var dateformat = "MMMM Do YYYY, HH:mm";
|
||||
|
||||
// get the database min timestamp
|
||||
var mintimestamp;
|
||||
$.getJSON(
|
||||
"http://192.168.0.201/admin/api_db.php?getMinTimestamp=true",
|
||||
function (ts) {
|
||||
mintimestamp = ((ts.mintimestamp) * 1000) || 0; // return the number times 1000 or zero (in case of NaN)
|
||||
}
|
||||
);
|
||||
|
||||
$(function () {
|
||||
$("#querytime").daterangepicker(
|
||||
{
|
||||
@@ -24,6 +33,8 @@ $(function () {
|
||||
locale: { format: dateformat },
|
||||
startDate: start__,
|
||||
endDate: end__,
|
||||
minDate: moment(mintimestamp), // Use the oldest timestamp found in database as initial date
|
||||
maxDate: moment(), // Use now as maximum date
|
||||
ranges: {
|
||||
Today: [moment().startOf("day"), moment()],
|
||||
Yesterday: [
|
||||
@@ -69,19 +80,21 @@ function updateQueriesOverTime() {
|
||||
// Default displaying axis scaling
|
||||
timeLineChart.options.scales.xAxes[0].time.unit = "hour";
|
||||
|
||||
if (num * interval >= 6 * 29 * 24 * 60 * 60) {
|
||||
// If the requested data is more than 3 months, set ticks interval to quarterly
|
||||
// Xaxis scaling based on selected daterange
|
||||
if (num * interval >= 5 * 365 * 24 * 60 *60) {
|
||||
// If the requested data is more than 5 years, set ticks interval to year
|
||||
timeLineChart.options.scales.xAxes[0].time.unit = "year";
|
||||
} else if (num * interval >= 366 * 24 * 60 * 60) {
|
||||
// If the requested data is more than 1 year, set ticks interval to quarter
|
||||
timeLineChart.options.scales.xAxes[0].time.unit = "quarter";
|
||||
} else if (num * interval >= 3 * 29 * 24 * 60 * 60) {
|
||||
} else if (num * interval >= 92 * 24 * 60 * 60) {
|
||||
// If the requested data is more than 3 months, set ticks interval to months
|
||||
timeLineChart.options.scales.xAxes[0].time.unit = "month";
|
||||
}
|
||||
|
||||
if (num * interval >= 29 * 24 * 60 * 60) {
|
||||
// If the requested data is more than 1 month, set ticks interval to weeks
|
||||
} else if (num * interval >= 31 * 24 * 60 * 60) {
|
||||
// If the requested data is 1 month or more, set ticks interval to weeks
|
||||
timeLineChart.options.scales.xAxes[0].time.unit = "week";
|
||||
} else if (num * interval >= 6 * 24 * 60 * 60) {
|
||||
// If the requested data is more than 1 week, set ticks interval to days
|
||||
} else if (num * interval > 3 * 24 * 60 * 60) {
|
||||
// If the requested data is more than 3 days (72 hours), set ticks interval to days
|
||||
timeLineChart.options.scales.xAxes[0].time.unit = "day";
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user