Skip to content

Commit

Permalink
- changed config logic, should work now as expected
Browse files Browse the repository at this point in the history
  • Loading branch information
mentalilll committed Apr 1, 2024
1 parent d297f99 commit 6de5ced
Show file tree
Hide file tree
Showing 2 changed files with 55 additions and 28 deletions.
25 changes: 13 additions & 12 deletions dist/chart.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ export const chart = {
this.fetchDataForSensors();
}, 3600000);
}
if (this.enable_tooltip) {

this.content.addEventListener('mouseover', (event) => {
if (event.target.classList.contains('cell')) {
this.buildMouseTooltip(event.target);
Expand All @@ -76,7 +76,7 @@ export const chart = {
}
}, 100);
});
}

}

this.buildTooltip();
Expand Down Expand Up @@ -145,17 +145,18 @@ export const chart = {
verticalLine.className = 'vertical-line vertical-line-' + indexString;
verticalLine.setAttribute('data-index', indexString);
verticalLine.style.left = `calc(${percentageHumidity}% - 0.5px)`;

let tooltip = this.querySelector(`.custom-tooltip[data-index="${index}"]`) || document.createElement('div');
tooltip.className = 'custom-tooltip custom-tooltip-' + indexString;
tooltip.setAttribute('data-index', indexString);
tooltip.innerHTML = `<strong>${sensor.name}:</strong> kPa: ${vpd} | ${this.rh_text}: ${humidity}% | ${this.air_text}: ${temperature}°C`;
tooltip.style.left = `${percentageHumidity}%`;
tooltip.style.bottom = `${100 - percentageTemperature}%`;

if (!pointer.isConnected) {
sensors.appendChild(tooltip);
if (this.enable_tooltip) {
let tooltip = this.querySelector(`.custom-tooltip[data-index="${index}"]`) || document.createElement('div');
tooltip.className = 'custom-tooltip custom-tooltip-' + indexString;
tooltip.setAttribute('data-index', indexString);
tooltip.innerHTML = `<strong>${sensor.name}:</strong> kPa: ${vpd} | ${this.rh_text}: ${humidity}% | ${this.air_text}: ${temperature}°C`;
tooltip.style.left = `${percentageHumidity}%`;
tooltip.style.bottom = `${100 - percentageTemperature}%`;
if (!pointer.isConnected) {
sensors.appendChild(tooltip);
}
}

if (!pointer.isConnected) {
sensors.appendChild(pointer);
}
Expand Down
58 changes: 42 additions & 16 deletions dist/ha-vpd-chart.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,22 +62,48 @@ class HaVpdChart extends HTMLElement {
throw new Error('You need to define sensors');
}

this.vpd_phases = config.vpd_phases || this.vpd_phases;
this.sensors = config.sensors || this.sensors;
this.air_text = config.air_text || "Air";
this.rh_text = config.rh_text || "RH";
this.min_temperature = config.min_temperature || this.min_temperature;
this.max_temperature = config.max_temperature || this.max_temperature;
this.min_humidity = config.min_humidity || this.min_humidity;
this.max_humidity = config.max_humidity || this.max_humidity;
this.steps_temperature = config.steps_temperature || this.steps_temperature;
this.steps_humidity = config.steps_humidity || this.steps_humidity;
this.is_bar_view = config.is_bar_view || this.is_bar_view;
this.enable_axes = config.enable_axes || this.enable_axes;
this.enable_tooltip = config.enable_tooltip || this.enable_tooltip;
this.enable_ghostmap = config.enable_ghostmap || this.enable_ghostmap;
this.enable_triangle = config.enable_triangle || this.enable_triangle;

if('vpd_phases' in config) {
this.vpd_phases = config.vpd_phases;
}
if('sensors' in config) {
this.sensors = config.sensors;
}
if('air_text' in config) {
this.air_text = config.air_text;
}
if('rh_text' in config) {
this.rh_text = config.rh_text;
}
if('min_temperature' in config) {
this.min_temperature = config.min_temperature;
}
if('max_temperature' in config) {
this.max_temperature = config.max_temperature;
}
if('min_humidity' in config) {
this.min_humidity = config.min_humidity;
}
if('max_humidity' in config) {
this.max_humidity = config.max_humidity;
}
if('steps_temperature' in config) {
this.steps_temperature = config.steps_temperature;
}
if('steps_humidity' in config) {
this.steps_humidity = config.steps_humidity;
}
if('is_bar_view' in config) {
this.is_bar_view = config.is_bar_view;
}
if('enable_axes' in config) {
this.enable_axes = config.enable_axes;
}
if('enable_ghostmap' in config) {
this.enable_ghostmap = config.enable_ghostmap;
}
if('enable_tooltip' in config) {
this.enable_tooltip = config.enable_tooltip;
}
}

getCardSize() {
Expand Down

0 comments on commit 6de5ced

Please sign in to comment.