diff --git a/src/graph_line_archive_config.inc b/src/graph_line_archive_config.inc new file mode 100644 index 0000000..6f55697 --- /dev/null +++ b/src/graph_line_archive_config.inc @@ -0,0 +1,80 @@ +#encoding UTF-8 +## +-----------------------------------------------------------------------------------+ +## | graph_line_archive_config.inc JS config for default line charts | +## +-----------------------------------------------------------------------------------+ + +chart: { + type: 'line', + zoom: { + enabled: false, + type: 'x', + autoScaleYaxis: false, + }, +}, + +dataLabels: { + enabled: false +}, + +stroke: { + width: 0, +}, + +plotOptions: { + line: { + borderRadius: 2, + } +}, + +fill: { + opacity: 0.7 +}, + +markers: { + size: 4, + strokeWidth: 1, + strokeOpacity: 0.5, + strokeDashArray: 0, + fillOpacity: 0.7, + shape: "circle", + radius: 1, +}, + +xaxis: { + type: 'datetime', + tickAmount: 8, + trim: true, + labels: { + hideOverlappingLabels: true, + tickAmount: 8, + rotateAlways: false, + hideOverlappingLabels: true, + showDuplicates: false, + trim: true, + formatter: function(val, timestamp) { + return moment.unix(timestamp).format("$Extras.Formatting.datetime_graph_archive"); + } + } +}, + +grid: { + show: true, + strokeDashArray: 0, + position: 'back', + xaxis: { + lines: { + show: true + } + }, + yaxis: { + lines: { + show: true + } + }, +}, + +tooltip: { + x: { + format: "$Extras.Formatting.datetime_graph_tooltip" + } +}, diff --git a/src/graph_line_config.inc b/src/graph_line_config.inc new file mode 100644 index 0000000..cd73c19 --- /dev/null +++ b/src/graph_line_config.inc @@ -0,0 +1,80 @@ +#encoding UTF-8 +## +---------------------------------------------------------------------------+ +## | graph_line_config.inc JS config for default line charts | +## +---------------------------------------------------------------------------+ + +chart: { + type: 'line', + zoom: { + enabled: false, + type: 'x', + autoScaleYaxis: false, + }, +}, + +dataLabels: { + enabled: false +}, + +stroke: { + width: 0, +}, + +plotOptions: { + line: { + borderRadius: 2, + } +}, + +fill: { + opacity: 0.7 +}, + +markers: { + size: 4, + strokeWidth: 1, + strokeOpacity: 0.5, + strokeDashArray: 0, + fillOpacity: 0.7, + shape: "circle", + radius: 1, +}, + +xaxis: { + type: 'datetime', + tickAmount: 8, + trim: true, + labels: { + hideOverlappingLabels: true, + tickAmount: 8, + rotateAlways: false, + hideOverlappingLabels: true, + showDuplicates: false, + trim: true, + formatter: function(val, timestamp) { + return moment.unix(timestamp).format("$Extras.Formatting.datetime_graph_label"); + } + } +}, + +grid: { + show: true, + strokeDashArray: 0, + position: 'back', + xaxis: { + lines: { + show: true + } + }, + yaxis: { + lines: { + show: true + } + }, +}, + +tooltip: { + x: { + format: "$Extras.Formatting.datetime_graph_tooltip" + } +}, diff --git a/src/index.html.tmpl b/src/index.html.tmpl index 23a0cf1..e57b51a 100644 --- a/src/index.html.tmpl +++ b/src/index.html.tmpl @@ -230,11 +230,16 @@ new ApexCharts(document.querySelector('#$id'), { ...graph_${type}_config, yaxis: { - labels: { - formatter: function (val) { - return formatNumber(val, "$getVar('unit.format.' + name)") + "$getVar('unit.label.' + name)"; - } - } + #if $name == "windDir" + max: 360, + min: 0, + tickAmount: 8, + #end if + labels: { + formatter: function (val) { + return formatNumber(val, "$getVar('unit.format.' + name)") + "$getVar('unit.label.' + name)"; + } + }, }, series: [ { @@ -279,10 +284,12 @@ new ApexCharts(document.querySelector('#$id'), { var graph_bar_config = { #include "graph_bar_config.inc" } - var graph_radar_config = { #include "graph_radar_config.inc" } + var graph_line_config = { + #include "graph_line_config.inc" + } // outTemp + Dewpoint $getChartJsCode("outTemp", "outTempchart", "area", "outTemp", "dewpoint") @@ -302,6 +309,7 @@ new ApexCharts(document.querySelector('#$id'), { // Wind $getChartJsCode("windSpeed", "windSpeedchart", "area", "windSpeed", "windGust", "max") + $getChartJsCode("windDir", "windDirchart", "line", "windDir") // outHumidity $getChartJsCode("outHumidity", "outHumiditychart", "area", "outHumidity") diff --git a/src/month-%Y-%m.html.tmpl b/src/month-%Y-%m.html.tmpl index 4afb10e..0f7fea2 100644 --- a/src/month-%Y-%m.html.tmpl +++ b/src/month-%Y-%m.html.tmpl @@ -218,11 +218,11 @@ new ApexCharts(document.querySelector('#$id'), { ...graph_${type}_config, yaxis: { - labels: { - formatter: function (val) { - return formatNumber(val, "$getVar('unit.format.' + name)") + "$getVar('unit.label.' + name)"; - } - } + labels: { + formatter: function (val) { + return formatNumber(val, "$getVar('unit.format.' + name)") + "$getVar('unit.label.' + name)"; + } + }, }, series: [ { @@ -259,11 +259,16 @@ new ApexCharts(document.querySelector('#$id'), { new ApexCharts(document.querySelector('#$id'), { ...graph_${type}_config, yaxis: { - labels: { - formatter: function (val) { - return formatNumber(val, "$getVar('unit.format.' + name)") + "$getVar('unit.label.' + name)"; - } - } + #if $name == "windDir" + max: 360, + min: 0, + tickAmount: 8, + #end if + labels: { + formatter: function (val) { + return formatNumber(val, "$getVar('unit.format.' + name)") + "$getVar('unit.label.' + name)"; + } + }, }, series: [ { @@ -310,10 +315,12 @@ new ApexCharts(document.querySelector('#$id'), { var graph_bar_config = { #include "graph_bar_archive_config.inc" } - var graph_radar_config = { #include "graph_radar_config.inc" } + var graph_line_config = { + #include "graph_line_archive_config.inc" + } // outTemp + Dewpoint $getChartJsCode("outTemp", "outTempchart", "area", "outTemp", "dewpoint") @@ -333,6 +340,7 @@ new ApexCharts(document.querySelector('#$id'), { // Wind $getChartJsCode("windSpeed", "windSpeedchart", "area", "windSpeed", "windGust", "max") + $getChartJsCode("windDir", "windDirchart", "line", "windDir") // outHumidity $getChartJsCode("outHumidity", "outHumiditychart", "area", "outHumidity") diff --git a/src/month.html.tmpl b/src/month.html.tmpl index ef16405..189f51e 100644 --- a/src/month.html.tmpl +++ b/src/month.html.tmpl @@ -212,11 +212,16 @@ new ApexCharts(document.querySelector('#$id'), { ...graph_${type}_config, yaxis: { - labels: { - formatter: function (val) { - return formatNumber(val, "$getVar('unit.format.' + name)") + "$getVar('unit.label.' + name)"; - } - } + #if $name == "windDir" + max: 360, + min: 0, + tickAmount: 8, + #end if + labels: { + formatter: function (val) { + return formatNumber(val, "$getVar('unit.format.' + name)") + "$getVar('unit.label.' + name)"; + } + }, }, series: [ { @@ -255,6 +260,10 @@ new ApexCharts(document.querySelector('#$id'), {