From 13c2a63abbdf1f6efe1e6b5c9d835aead9e74806 Mon Sep 17 00:00:00 2001 From: William Troup Date: Fri, 19 Jan 2024 16:55:45 +0000 Subject: [PATCH 01/19] Updated to v1.2.0. --- README.md | 6 +++--- README_NUGET.md | 6 +++--- dist/heat.js | 4 ++-- dist/heat.js.css | 2 +- dist/heat.js.min.css | 2 +- dist/heat.min.js | 4 ++-- dist/translations/heat.translations.ar.js | 2 +- dist/translations/heat.translations.bn.js | 2 +- dist/translations/heat.translations.de.js | 2 +- dist/translations/heat.translations.en.js | 2 +- dist/translations/heat.translations.es.js | 2 +- dist/translations/heat.translations.fr.js | 2 +- dist/translations/heat.translations.hi.js | 2 +- dist/translations/heat.translations.ja.js | 2 +- dist/translations/heat.translations.pl.js | 2 +- dist/translations/heat.translations.pt.js | 2 +- dist/translations/heat.translations.tr.js | 2 +- dist/translations/heat.translations.zh.js | 2 +- docs/CHANGE_LOG.md | 6 ++++++ heat.js.nuspec | 2 +- package.json | 2 +- src/heat.js | 4 ++-- src/heat.js.scss | 2 +- 23 files changed, 35 insertions(+), 29 deletions(-) diff --git a/README.md b/README.md index 3939e26d..d64a4420 100644 --- a/README.md +++ b/README.md @@ -2,15 +2,15 @@ Heat.js [![Tweet](https://img.shields.io/twitter/url/http/shields.io.svg?style=social)](https://twitter.com/intent/tweet?text=Heat.js%2C%20a%20free%20JavaScript%heat%20map&url=https://github.com/williamtroup/Heat.js&hashtags=javascript,heat,map) -[![npm](https://img.shields.io/badge/npmjs-v1.1.0-blue)](https://www.npmjs.com/package/jheat.js) -[![nuget](https://img.shields.io/badge/nuget-v1.1.0-purple)](https://www.nuget.org/packages/jHeat.js/) +[![npm](https://img.shields.io/badge/npmjs-v1.2.0-blue)](https://www.npmjs.com/package/jheat.js) +[![nuget](https://img.shields.io/badge/nuget-v1.2.0-purple)](https://www.nuget.org/packages/jHeat.js/) [![license](https://img.shields.io/badge/license-MIT-green)](https://github.com/williamtroup/Heat.js/blob/main/LICENSE.txt) [![discussions Welcome](https://img.shields.io/badge/discussions-Welcome-red)](https://github.com/williamtroup/Heat.js/discussions) [![coded by William Troup](https://img.shields.io/badge/coded_by-William_Troup-yellow)](https://github.com/williamtroup) >

🌞 A lightweight JavaScript library that generates customizable heat maps to visualize date-based activity and trends.

->

v1.1.0

+>

v1.2.0


![Heat.js](docs/images/main.png) diff --git a/README_NUGET.md b/README_NUGET.md index 71980d96..78faed46 100644 --- a/README_NUGET.md +++ b/README_NUGET.md @@ -1,8 +1,8 @@ -# Heat.js v1.1.0 +# Heat.js v1.2.0 [![Tweet](https://img.shields.io/twitter/url/http/shields.io.svg?style=social)](https://twitter.com/intent/tweet?text=Heat.js%2C%20a%20free%20JavaScript%heat%20map&url=https://github.com/williamtroup/Heat.js&hashtags=javascript,heat,map) -[![npm](https://img.shields.io/badge/npmjs-v1.1.0-blue)](https://www.npmjs.com/package/jheat.js) -[![nuget](https://img.shields.io/badge/nuget-v1.1.0-purple)](https://www.nuget.org/packages/jHeat.js/) +[![npm](https://img.shields.io/badge/npmjs-v1.2.0-blue)](https://www.npmjs.com/package/jheat.js) +[![nuget](https://img.shields.io/badge/nuget-v1.2.0-purple)](https://www.nuget.org/packages/jHeat.js/) [![license](https://img.shields.io/badge/license-MIT-green)](https://github.com/williamtroup/Heat.js/blob/main/LICENSE.txt) [![discussions Welcome](https://img.shields.io/badge/discussions-Welcome-red)](https://github.com/williamtroup/Heat.js/discussions) [![coded by William Troup](https://img.shields.io/badge/coded_by-William_Troup-yellow)](https://github.com/williamtroup) diff --git a/dist/heat.js b/dist/heat.js index d5812a32..3b7d79a5 100644 --- a/dist/heat.js +++ b/dist/heat.js @@ -1,4 +1,4 @@ -/*! Heat.js v1.1.0 | (c) Bunoon 2024 | MIT License */ +/*! Heat.js v1.2.0 | (c) Bunoon 2024 | MIT License */ (function() { function render() { var tagTypes = _configuration.domElementTypes; @@ -763,7 +763,7 @@ return this; }; this.getVersion = function() { - return "1.1.0"; + return "1.2.0"; }; (function(documentObject, windowObject) { _parameter_Document = documentObject; diff --git a/dist/heat.js.css b/dist/heat.js.css index d80a21eb..ee7f5db8 100644 --- a/dist/heat.js.css +++ b/dist/heat.js.css @@ -1,5 +1,5 @@ /* - * Heat.js Library v1.1.0 + * Heat.js Library v1.2.0 * * Copyright 2024 Bunoon * Released under the MIT License diff --git a/dist/heat.js.min.css b/dist/heat.js.min.css index 73778f8c..802cea67 100644 --- a/dist/heat.js.min.css +++ b/dist/heat.js.min.css @@ -1,2 +1,2 @@ -/*! Heat.js v1.1.0 | (c) Bunoon 2024 | MIT License */ +/*! Heat.js v1.2.0 | (c) Bunoon 2024 | MIT License */ :root{--heat-js-color-black:#3b3a3a;--heat-js-color-white:#F5F5F5;--heat-js-color-gray:#AAA;--heat-js-container-background-color:#22272e;--heat-js-container-border-color:#454c56;--heat-js-day-background-color:#2d333b;--heat-js-day-border-color:#454c56;--heat-js-day-background-color-hover:#454c56;--heat-js-day-spacing:6.3px;--heat-js-button-background-color:#2d333b;--heat-js-button-border-color:#454c56;--heat-js-button-background-color-hover:#454c56;--heat-js-border-radius:.5rem;--heat-js-border-radius-day:.25rem;--heat-js-border-size:.5px;--heat-js-border-size-day:1px;--heat-js-spacing:10px;--heat-js-spacing-font-size:.85rem;--heat-js-transition:all .3s}div.heat-js{-moz-user-select:none;-webkit-user-select:none;-ms-user-select:none;-o-user-select:none;user-select:none;cursor:default;display:inline-block;border-radius:var(--heat-js-border-radius);background-color:var(--heat-js-container-background-color);color:var(--heat-js-color-white);border:var(--heat-js-border-size) solid var(--heat-js-container-border-color);padding:var(--heat-js-spacing);font-size:var(--heat-js-spacing-font-size);width:100%;max-width:700px}div.heat-js *{box-sizing:border-box;line-height:normal}div.heat-js *::before,div.heat-js *::after{box-sizing:border-box;line-height:normal}div.heat-js div.title-bar{text-align:right;margin-bottom:var(--heat-js-spacing)}div.heat-js div.title-bar div.title{float:left;font-weight:800;font-size:1.2rem}div.heat-js div.title-bar button{background-color:var(--heat-js-button-background-color);border:var(--heat-js-border-size) solid var(--heat-js-button-border-color);color:var(--heat-js-color-white);border-radius:var(--heat-js-border-radius);padding-top:5px;padding-bottom:5px;padding-left:9px;padding-right:9px;outline:none}div.heat-js div.title-bar button:hover{cursor:pointer;background:var(--heat-js-button-background-color-hover);transition:var(--heat-js-transition)}div.heat-js div.title-bar button.active{cursor:default;background:var(--heat-js-button-background-color-hover);transition:var(--heat-js-transition)}div.heat-js div.title-bar button.back{margin-left:calc(var(--heat-js-spacing) * 2)!important}div.heat-js div.title-bar button.export{margin-right:calc(var(--heat-js-spacing) / 2)!important}div.heat-js div.title-bar div.year-text{margin-left:var(--heat-js-spacing);margin-right:var(--heat-js-spacing);display:inline-block}div.heat-js div.map-contents{overflow-y:scroll}div.heat-js div.map-contents div.map{display:inline-flex;flex-direction:row}div.heat-js div.map-contents div.map div.days{background-color:var(--heat-js-container-background-color);padding-right:calc(var(--heat-js-spacing) * 3);padding-top:calc(var(--heat-js-spacing-font-size) + var(--heat-js-spacing) + 1px);position:sticky;left:0}div.heat-js div.map-contents div.map div.days div.day-name{font-weight:300;margin-bottom:4px}div.heat-js div.map-contents div.map div.months{display:flex;justify-content:space-between;flex-grow:1}div.heat-js div.map-contents div.map div.months div.month{flex:1;pointer-events:none}div.heat-js div.map-contents div.map div.months div.month:last-child{margin-right:0}div.heat-js div.map-contents div.map div.months div.month div.month-name,div.heat-js div.map-contents div.map div.months div.month div.month-name-bottom{font-weight:300}div.heat-js div.map-contents div.map div.months div.month div.month-name{margin-bottom:var(--heat-js-spacing)}div.heat-js div.map-contents div.map div.months div.month div.month-name-bottom{margin-top:var(--heat-js-spacing)}div.heat-js div.map-contents div.map div.months div.month div.day-columns{display:flex;justify-content:space-between}div.heat-js div.map-contents div.map div.months div.month div.day-columns div.day-column div.day,div.heat-js div.map-contents div.map div.months div.month div.day-columns div.day-column div.day-disabled{border-radius:var(--heat-js-border-radius-day);width:var(--heat-js-spacing-font-size);height:var(--heat-js-spacing-font-size);margin-right:var(--heat-js-day-spacing);margin-bottom:var(--heat-js-day-spacing)}div.heat-js div.map-contents div.map div.months div.month div.day-columns div.day-column div.day:last-child,div.heat-js div.map-contents div.map div.months div.month div.day-columns div.day-column div.day-disabled:last-child{margin-bottom:0}div.heat-js div.map-contents div.map div.months div.month div.day-columns div.day-column div.day{pointer-events:all!important;background-color:var(--heat-js-day-background-color);border:var(--heat-js-border-size) solid var(--heat-js-day-border-color)}div.heat-js div.map-contents div.map div.months div.month div.day-columns div.day-column div.day:hover{cursor:pointer;background:var(--heat-js-day-background-color-hover);transition:var(--heat-js-transition)}div.heat-js div.guide{margin-top:calc(var(--heat-js-spacing) + var(--heat-js-spacing) / 2);display:flex}div.heat-js div.guide div.map-types,div.heat-js div.guide div.map-toggles{flex-basis:100%}div.heat-js div.guide div.map-types{text-align:left}div.heat-js div.guide div.map-types button{background-color:var(--heat-js-button-background-color);border:var(--heat-js-border-size) solid var(--heat-js-button-border-color);color:var(--heat-js-color-white);border-radius:var(--heat-js-border-radius);padding-top:5px;padding-bottom:5px;padding-left:9px;padding-right:9px;outline:none}div.heat-js div.guide div.map-types button:hover{cursor:pointer;background:var(--heat-js-button-background-color-hover);transition:var(--heat-js-transition)}div.heat-js div.guide div.map-types button.active{cursor:default;background:var(--heat-js-button-background-color-hover);transition:var(--heat-js-transition)}div.heat-js div.guide div.map-types button{margin-left:0!important;margin-right:var(--heat-js-spacing)!important}div.heat-js div.guide div.map-toggles{text-align:right;display:flex;align-items:center;justify-content:right}div.heat-js div.guide div.map-toggles div.no-click{pointer-events:none}div.heat-js div.guide div.map-toggles div.less-text,div.heat-js div.guide div.map-toggles div.more-text{display:inline-block;font-weight:300}div.heat-js div.guide div.map-toggles div.less-text:hover,div.heat-js div.guide div.map-toggles div.more-text:hover{cursor:pointer;text-decoration:underline}div.heat-js div.guide div.map-toggles div.less-text{margin-right:var(--heat-js-spacing)}div.heat-js div.guide div.map-toggles div.more-text{margin-left:var(--heat-js-spacing)}div.heat-js div.guide div.map-toggles div.days{display:inline-flex;align-items:center;justify-content:right}div.heat-js div.guide div.map-toggles div.days div.day{background-color:var(--heat-js-day-background-color);border:var(--heat-js-border-size) solid var(--heat-js-day-border-color);display:inline-block;border-radius:var(--heat-js-border-radius-day);width:var(--heat-js-spacing-font-size);height:var(--heat-js-spacing-font-size);margin-right:var(--heat-js-day-spacing);cursor:pointer}div.heat-js div.guide div.map-toggles div.days div.day:last-child{margin-right:0}div.heat-js div.day-color-1{background-color:rgba(57,211,83,.25)!important;border:var(--heat-js-border-size-day) solid rgba(57,211,83,.15)!important}div.heat-js div.day-color-1:hover{opacity:.7}div.heat-js div.day-color-2{background-color:rgba(57,211,83,.5)!important;border:var(--heat-js-border-size-day) solid rgba(57,211,83,.25)!important}div.heat-js div.day-color-2:hover{opacity:.7}div.heat-js div.day-color-3{background-color:rgba(57,211,83,.75)!important;border:var(--heat-js-border-size-day) solid rgba(57,211,83,.5)!important}div.heat-js div.day-color-3:hover{opacity:.7}div.heat-js div.day-color-4{background-color:rgb(57,211,83)!important;border:var(--heat-js-border-size-day) solid rgba(57,211,83,.75)!important}div.heat-js div.day-color-4:hover{opacity:.7} \ No newline at end of file diff --git a/dist/heat.min.js b/dist/heat.min.js index 56b8f208..47ca0a49 100644 --- a/dist/heat.min.js +++ b/dist/heat.min.js @@ -1,4 +1,4 @@ -/*! Heat.js v1.1.0 | (c) Bunoon 2024 | MIT License */ +/*! Heat.js v1.2.0 | (c) Bunoon 2024 | MIT License */ (function(){function t(a){a.element.className="heat-js";a.element.innerHTML=q.empty;X(a);Y(a)}function X(a){N(a.currentView.year)||(a.currentView.year=(new Date).getFullYear());if(a.showTitle||a.showYearSelector||a.showRefreshButton||a.showExportButton){var c=n("div","title-bar");a.element.appendChild(c);if(a.showTitle){var b=n("div","title");b.innerHTML=a.titleText;c.appendChild(b)}a.showExportButton&&(b=n("button","export"),b.innerHTML=f.exportButtonText,c.appendChild(b),b.onclick=function(){var e= k[a.element.id].type[a.currentView.type];var g=[];var h=[];g.push([D(f.dateText),D(f.countText)].join());for(var l in e)e.hasOwnProperty(l)&&h.push(l);h.sort();if(a.exportOnlyYearBeingViewed)for(h=0;12>h;h++){l=(new Date(a.currentView.year,h+1,0)).getDate();for(var p=0;p + + ## Version 1.1.0: #### **Translations:** diff --git a/heat.js.nuspec b/heat.js.nuspec index 24e09110..95bef655 100644 --- a/heat.js.nuspec +++ b/heat.js.nuspec @@ -2,7 +2,7 @@ jHeat.js - 1.1.0 + 1.2.0 Heat.js A lightweight JavaScript library that generates customizable heat maps to visualize date-based activity and trends. William Troup diff --git a/package.json b/package.json index 2f499843..2500ba03 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "name": "jheat.js", "title": "Heat.js", "description": "A lightweight JavaScript library that generates customizable heat maps to visualize date-based activity and trends.", - "version": "1.1.0", + "version": "1.2.0", "main": "dist/heat.js", "homepage": "https://www.william-troup.com/heat-js/", "author": { diff --git a/src/heat.js b/src/heat.js index 80da5035..83cf6dc1 100644 --- a/src/heat.js +++ b/src/heat.js @@ -4,7 +4,7 @@ * A lightweight JavaScript library that generates customizable heat maps to visualize date-based activity and trends. * * @file observe.js - * @version v1.1.0 + * @version v1.2.0 * @author Bunoon * @license MIT License * @copyright Bunoon 2024 @@ -1275,7 +1275,7 @@ * @returns {string} The version number. */ this.getVersion = function() { - return "1.1.0"; + return "1.2.0"; }; diff --git a/src/heat.js.scss b/src/heat.js.scss index c1415eb9..bfd940d0 100644 --- a/src/heat.js.scss +++ b/src/heat.js.scss @@ -1,5 +1,5 @@ /* - * Heat.js Library v1.1.0 + * Heat.js Library v1.2.0 * * Copyright 2024 Bunoon * Released under the MIT License From 36c83ee18e036784ec367339da1c2674bd5ec731 Mon Sep 17 00:00:00 2001 From: William Troup Date: Fri, 19 Jan 2024 16:58:13 +0000 Subject: [PATCH 02/19] Fixed a fault that prevented decimal values for CSS margins being converted correctly. --- dist/heat.js | 2 +- dist/heat.min.js | 2 +- docs/CHANGE_LOG.md | 4 +++- src/heat.js | 2 +- 4 files changed, 6 insertions(+), 4 deletions(-) diff --git a/dist/heat.js b/dist/heat.js index 3b7d79a5..47072868 100644 --- a/dist/heat.js +++ b/dist/heat.js @@ -536,7 +536,7 @@ value = element.currentStyle[stylePropertyName]; } if (toNumber) { - value = parseInt(value, 10); + value = parseFloat(value, 10); } return value; } diff --git a/dist/heat.min.js b/dist/heat.min.js index 47ca0a49..1e91ca29 100644 --- a/dist/heat.min.js +++ b/dist/heat.min.js @@ -13,7 +13,7 @@ n("div");e.title=b.tooltipText;c.appendChild(e);R(a,b.id)?e.className="day "+b.c function U(a,c){k[a]={options:c,type:{},types:1};k[a].type.None={}}function T(a,c){for(var b=a.mapRangeColors.length,e=0;ea.getDay()-1?6:a.getDay()-1}function ea(a,c){var b=a,e=Q(c);b=b.replace("{dddd}",f.dayNames[e]);b=b.replace("{dd}",z(c.getDate()));b=b.replace("{d}",c.getDate()); e=b.replace;var g=c.getDate(),h=f.thText;if(31===g||21===g||1===g)h=f.stText;else if(22===g||2===g)h=f.ndText;else if(23===g||3===g)h=f.rdText;b=e.call(b,"{o}",h);b=b.replace("{mmmm}",f.monthNames[c.getMonth()]);b=b.replace("{mm}",z(c.getMonth()+1));b=b.replace("{m}",c.getMonth()+1);b=b.replace("{yyyy}",c.getFullYear());b=b.replace("{yyy}",c.getFullYear().toString().substring(1));b=b.replace("{yy}",c.getFullYear().toString().substring(2));return b=b.replace("{y}",parseInt(c.getFullYear().toString().substring(2)).toString())} function w(a){return null!==a&&void 0!==a&&a!==q.empty}function J(a){return w(a)&&"object"===typeof a}function K(a){return w(a)&&"boolean"===typeof a}function B(a){return w(a)&&"string"===typeof a}function I(a){return w(a)&&"function"===typeof a}function N(a){return w(a)&&"number"===typeof a}function O(a){return J(a)&&a instanceof Array}function n(a,c){var b=a.toLowerCase();var e="text"===b;P.hasOwnProperty(b)||(P[b]=e?A.createTextNode(q.empty):A.createElement(b));b=P[b].cloneNode(!1);w(c)&&(b.className= -c);return b}function S(a,c,b){var e=null;b=w(b)?b:!1;L.getComputedStyle?e=A.defaultView.getComputedStyle(a,null).getPropertyValue(c):a.currentStyle&&(e=a.currentStyle[c]);b&&(e=parseInt(e,10));return e}function u(a){I(a)&&a.apply(null,[].slice.call(arguments,1))}function r(a,c){return B(a)?a:c}function x(a,c){return K(a)?a:c}function y(a,c){return I(a)?a:c}function ia(a){var c=!0,b=null;try{B(a)&&(b=JSON.parse(a))}catch(e){try{b=eval("("+a+")"),I(b)&&(b=b())}catch(g){f.safeMode||(console.error("Errors in object: "+ +c);return b}function S(a,c,b){var e=null;b=w(b)?b:!1;L.getComputedStyle?e=A.defaultView.getComputedStyle(a,null).getPropertyValue(c):a.currentStyle&&(e=a.currentStyle[c]);b&&(e=parseFloat(e,10));return e}function u(a){I(a)&&a.apply(null,[].slice.call(arguments,1))}function r(a,c){return B(a)?a:c}function x(a,c){return K(a)?a:c}function y(a,c){return I(a)?a:c}function ia(a){var c=!0,b=null;try{B(a)&&(b=JSON.parse(a))}catch(e){try{b=eval("("+a+")"),I(b)&&(b=b())}catch(g){f.safeMode||(console.error("Errors in object: "+ e.message+", "+g.message),c=!1),b=null}}return{parsed:c,result:b}}function V(){for(var a=[],c=0;32>c;c++){8!==c&&12!==c&&16!==c&&20!==c||a.push("-");var b=Math.floor(16*Math.random()).toString(16);a.push(b)}return a.join(q.empty)}function z(a){a=a.toString();return 1===a.length?"0"+a:a}function H(a){return a.getFullYear()+"-"+z(a.getMonth()+1)+"-"+z(a.getDate())}function W(){f.safeMode=x(f.safeMode,!0);var a=f,c=f.domElementTypes,b=["*"];B(c)?(c=c.split(q.space),0===c.length&&(c=b)):c=O(c)?c:b;a.domElementTypes= c;f.stText=r(f.stText,"st");f.ndText=r(f.ndText,"nd");f.rdText=r(f.rdText,"rd");f.thText=r(f.thText,"th");f.backButtonText=r(f.backButtonText,"Back");f.nextButtonText=r(f.nextButtonText,"Next");f.refreshButtonText=r(f.refreshButtonText,"Refresh");f.exportButtonText=r(f.exportButtonText,"Export");f.lessText=r(f.lessText,"Less");f.moreText=r(f.moreText,"More");f.dateText=r(f.dateText,"Date");f.countText=r(f.countText,"Count");M(f.monthNames,12)&&(f.monthNames="Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec".split(" ")); M(f.dayNames,7)&&(f.dayNames="Mon Tue Wed Thu Fri Sat Sun".split(" "))}function M(a,c){c=N(c)?c:1;return!O(a)||a.length diff --git a/src/heat.js b/src/heat.js index 83cf6dc1..ecc71780 100644 --- a/src/heat.js +++ b/src/heat.js @@ -780,7 +780,7 @@ } if ( toNumber ) { - value = parseInt( value, 10 ); + value = parseFloat( value, 10 ); } return value; From 4dfdb36001c93eb32305971ac8b19898c12dad29 Mon Sep 17 00:00:00 2001 From: William Troup Date: Fri, 19 Jan 2024 17:12:36 +0000 Subject: [PATCH 03/19] Added a new binding option called "year", which states the year that should be shown when the heat map is rendered for the first time (defaults to current year). --- dist/heat.js | 9 +++--- dist/heat.min.js | 52 ++++++++++++++++---------------- docs/CHANGE_LOG.md | 3 ++ docs/binding/OPTIONS.md | 1 + src/heat.js | 11 ++++--- test/dist/heat.js.bootstrap.html | 2 +- test/src/heat.js.bootstrap.html | 2 +- 7 files changed, 43 insertions(+), 37 deletions(-) diff --git a/dist/heat.js b/dist/heat.js index 47072868..df4cac62 100644 --- a/dist/heat.js +++ b/dist/heat.js @@ -27,7 +27,7 @@ bindingOptions.element = element; bindingOptions.currentView = {}; bindingOptions.currentView.colorsVisible = {}; - bindingOptions.currentView.year = null; + bindingOptions.currentView.year = bindingOptions.year; bindingOptions.currentView.type = _elements_DateCounts_DefaultType; fireCustomTrigger(bindingOptions.onBeforeRender, element); if (!isDefinedString(element.id)) { @@ -59,9 +59,6 @@ renderControlMap(bindingOptions); } function renderControlTitleBar(bindingOptions) { - if (!isDefinedNumber(bindingOptions.currentView.year)) { - bindingOptions.currentView.year = (new Date()).getFullYear(); - } if (bindingOptions.showTitle || bindingOptions.showYearSelector || bindingOptions.showRefreshButton || bindingOptions.showExportButton) { var titleBar = createElement("div", "title-bar"); bindingOptions.element.appendChild(titleBar); @@ -425,6 +422,7 @@ options.mapTogglesEnabled = getDefaultBoolean(options.mapTogglesEnabled, true); options.placeMonthNamesOnTheBottom = getDefaultBoolean(options.placeMonthNamesOnTheBottom, false); options.exportOnlyYearBeingViewed = getDefaultBoolean(options.exportOnlyYearBeingViewed, true); + options.year = getDefaultNumber(options.year, (new Date()).getFullYear()); if (isInvalidOptionArray(options.monthsToShow)) { options.monthsToShow = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]; } @@ -557,6 +555,9 @@ function getDefaultArray(value, defaultValue) { return isDefinedArray(value) ? value : defaultValue; } + function getDefaultNumber(value, defaultValue) { + return isDefinedNumber(value) ? value : defaultValue; + } function getDefaultStringOrArray(value, defaultValue) { if (isDefinedString(value)) { value = value.split(_string.space); diff --git a/dist/heat.min.js b/dist/heat.min.js index 1e91ca29..f094c38c 100644 --- a/dist/heat.min.js +++ b/dist/heat.min.js @@ -1,27 +1,27 @@ /*! Heat.js v1.2.0 | (c) Bunoon 2024 | MIT License */ -(function(){function t(a){a.element.className="heat-js";a.element.innerHTML=q.empty;X(a);Y(a)}function X(a){N(a.currentView.year)||(a.currentView.year=(new Date).getFullYear());if(a.showTitle||a.showYearSelector||a.showRefreshButton||a.showExportButton){var c=n("div","title-bar");a.element.appendChild(c);if(a.showTitle){var b=n("div","title");b.innerHTML=a.titleText;c.appendChild(b)}a.showExportButton&&(b=n("button","export"),b.innerHTML=f.exportButtonText,c.appendChild(b),b.onclick=function(){var e= -k[a.element.id].type[a.currentView.type];var g=[];var h=[];g.push([D(f.dateText),D(f.countText)].join());for(var l in e)e.hasOwnProperty(l)&&h.push(l);h.sort();if(a.exportOnlyYearBeingViewed)for(h=0;12>h;h++){l=(new Date(a.currentView.year,h+1,0)).getDate();for(var p=0;ph;h++)if(-1h;h++)if(-1=p)F=!0;else{var ca=n("div","day-disabled");d.appendChild(ca)}F&&(-1=l.minimum)e=l;else break;w(e)&&R(a,e.id)&&(b.className+=q.space+e.cssClassName);w(G)||(h=S(b,"margin-left",!0),c=S(b,"margin-right",!0),G=b.offsetWidth+h+c)}function Z(a){var c=n("div","guide");a.element.appendChild(c);var b=n("div","map-types"); -c.appendChild(b);var e=0;for(h in k[a.element.id].type.None)if(k[a.element.id].type.None.hasOwnProperty(h)){e++;break}if(1a.getDay()-1?6:a.getDay()-1}function ea(a,c){var b=a,e=Q(c);b=b.replace("{dddd}",f.dayNames[e]);b=b.replace("{dd}",z(c.getDate()));b=b.replace("{d}",c.getDate()); -e=b.replace;var g=c.getDate(),h=f.thText;if(31===g||21===g||1===g)h=f.stText;else if(22===g||2===g)h=f.ndText;else if(23===g||3===g)h=f.rdText;b=e.call(b,"{o}",h);b=b.replace("{mmmm}",f.monthNames[c.getMonth()]);b=b.replace("{mm}",z(c.getMonth()+1));b=b.replace("{m}",c.getMonth()+1);b=b.replace("{yyyy}",c.getFullYear());b=b.replace("{yyy}",c.getFullYear().toString().substring(1));b=b.replace("{yy}",c.getFullYear().toString().substring(2));return b=b.replace("{y}",parseInt(c.getFullYear().toString().substring(2)).toString())} -function w(a){return null!==a&&void 0!==a&&a!==q.empty}function J(a){return w(a)&&"object"===typeof a}function K(a){return w(a)&&"boolean"===typeof a}function B(a){return w(a)&&"string"===typeof a}function I(a){return w(a)&&"function"===typeof a}function N(a){return w(a)&&"number"===typeof a}function O(a){return J(a)&&a instanceof Array}function n(a,c){var b=a.toLowerCase();var e="text"===b;P.hasOwnProperty(b)||(P[b]=e?A.createTextNode(q.empty):A.createElement(b));b=P[b].cloneNode(!1);w(c)&&(b.className= -c);return b}function S(a,c,b){var e=null;b=w(b)?b:!1;L.getComputedStyle?e=A.defaultView.getComputedStyle(a,null).getPropertyValue(c):a.currentStyle&&(e=a.currentStyle[c]);b&&(e=parseFloat(e,10));return e}function u(a){I(a)&&a.apply(null,[].slice.call(arguments,1))}function r(a,c){return B(a)?a:c}function x(a,c){return K(a)?a:c}function y(a,c){return I(a)?a:c}function ia(a){var c=!0,b=null;try{B(a)&&(b=JSON.parse(a))}catch(e){try{b=eval("("+a+")"),I(b)&&(b=b())}catch(g){f.safeMode||(console.error("Errors in object: "+ -e.message+", "+g.message),c=!1),b=null}}return{parsed:c,result:b}}function V(){for(var a=[],c=0;32>c;c++){8!==c&&12!==c&&16!==c&&20!==c||a.push("-");var b=Math.floor(16*Math.random()).toString(16);a.push(b)}return a.join(q.empty)}function z(a){a=a.toString();return 1===a.length?"0"+a:a}function H(a){return a.getFullYear()+"-"+z(a.getMonth()+1)+"-"+z(a.getDate())}function W(){f.safeMode=x(f.safeMode,!0);var a=f,c=f.domElementTypes,b=["*"];B(c)?(c=c.split(q.space),0===c.length&&(c=b)):c=O(c)?c:b;a.domElementTypes= -c;f.stText=r(f.stText,"st");f.ndText=r(f.ndText,"nd");f.rdText=r(f.rdText,"rd");f.thText=r(f.thText,"th");f.backButtonText=r(f.backButtonText,"Back");f.nextButtonText=r(f.nextButtonText,"Next");f.refreshButtonText=r(f.refreshButtonText,"Refresh");f.exportButtonText=r(f.exportButtonText,"Export");f.lessText=r(f.lessText,"Less");f.moreText=r(f.moreText,"More");f.dateText=r(f.dateText,"Date");f.countText=r(f.countText,"Count");M(f.monthNames,12)&&(f.monthNames="Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec".split(" ")); -M(f.dayNames,7)&&(f.dayNames="Mon Tue Wed Thu Fri Sat Sun".split(" "))}function M(a,c){c=N(c)?c:1;return!O(a)||a.lengthh;h++){l=(new Date(a.currentView.year,h+1,0)).getDate();for(var p=0;ph;h++)if(-1h;h++)if(-1=p)C=!0;else{var ca=n("div","day-disabled");d.appendChild(ca)}C&&(-1< +a.daysToShow.indexOf(r)&&da(a,d,z-p,h,c,b),0===(z+1)%7&&(d=n("div","day-column"),m.appendChild(d),r=0));r++}a.showMonthNames&&a.placeMonthNamesOnTheBottom&&(m=n("div","month-name-bottom"),m.innerHTML=f.monthNames[h],l.appendChild(m));e&&w(G)&&(0=l.minimum)e=l;else break;w(e)&&R(a,e.id)&&(b.className+=q.space+e.cssClassName);w(G)||(h=S(b,"margin-left",!0),c=S(b,"margin-right",!0),G=b.offsetWidth+h+c)}function Z(a){var c=n("div","guide");a.element.appendChild(c);var b=n("div","map-types");c.appendChild(b);var e=0;for(h in k[a.element.id].type.None)if(k[a.element.id].type.None.hasOwnProperty(h)){e++; +break}if(1a.getDay()-1?6:a.getDay()-1}function ea(a,c){var b=a,e=Q(c);b=b.replace("{dddd}",f.dayNames[e]);b=b.replace("{dd}",A(c.getDate()));b=b.replace("{d}",c.getDate());e=b.replace;var g=c.getDate(),h=f.thText;if(31===g||21===g||1===g)h=f.stText;else if(22===g|| +2===g)h=f.ndText;else if(23===g||3===g)h=f.rdText;b=e.call(b,"{o}",h);b=b.replace("{mmmm}",f.monthNames[c.getMonth()]);b=b.replace("{mm}",A(c.getMonth()+1));b=b.replace("{m}",c.getMonth()+1);b=b.replace("{yyyy}",c.getFullYear());b=b.replace("{yyy}",c.getFullYear().toString().substring(1));b=b.replace("{yy}",c.getFullYear().toString().substring(2));return b=b.replace("{y}",parseInt(c.getFullYear().toString().substring(2)).toString())}function w(a){return null!==a&&void 0!==a&&a!==q.empty}function J(a){return w(a)&& +"object"===typeof a}function K(a){return w(a)&&"boolean"===typeof a}function D(a){return w(a)&&"string"===typeof a}function I(a){return w(a)&&"function"===typeof a}function N(a){return w(a)&&"number"===typeof a}function O(a){return J(a)&&a instanceof Array}function n(a,c){var b=a.toLowerCase();var e="text"===b;P.hasOwnProperty(b)||(P[b]=e?B.createTextNode(q.empty):B.createElement(b));b=P[b].cloneNode(!1);w(c)&&(b.className=c);return b}function S(a,c,b){var e=null;b=w(b)?b:!1;L.getComputedStyle?e= +B.defaultView.getComputedStyle(a,null).getPropertyValue(c):a.currentStyle&&(e=a.currentStyle[c]);b&&(e=parseFloat(e,10));return e}function v(a){I(a)&&a.apply(null,[].slice.call(arguments,1))}function t(a,c){return D(a)?a:c}function x(a,c){return K(a)?a:c}function y(a,c){return I(a)?a:c}function ia(a){var c=!0,b=null;try{D(a)&&(b=JSON.parse(a))}catch(e){try{b=eval("("+a+")"),I(b)&&(b=b())}catch(g){f.safeMode||(console.error("Errors in object: "+e.message+", "+g.message),c=!1),b=null}}return{parsed:c, +result:b}}function V(){for(var a=[],c=0;32>c;c++){8!==c&&12!==c&&16!==c&&20!==c||a.push("-");var b=Math.floor(16*Math.random()).toString(16);a.push(b)}return a.join(q.empty)}function A(a){a=a.toString();return 1===a.length?"0"+a:a}function H(a){return a.getFullYear()+"-"+A(a.getMonth()+1)+"-"+A(a.getDate())}function W(){f.safeMode=x(f.safeMode,!0);var a=f,c=f.domElementTypes,b=["*"];D(c)?(c=c.split(q.space),0===c.length&&(c=b)):c=O(c)?c:b;a.domElementTypes=c;f.stText=t(f.stText,"st");f.ndText=t(f.ndText, +"nd");f.rdText=t(f.rdText,"rd");f.thText=t(f.thText,"th");f.backButtonText=t(f.backButtonText,"Back");f.nextButtonText=t(f.nextButtonText,"Next");f.refreshButtonText=t(f.refreshButtonText,"Refresh");f.exportButtonText=t(f.exportButtonText,"Export");f.lessText=t(f.lessText,"Less");f.moreText=t(f.moreText,"More");f.dateText=t(f.dateText,"Date");f.countText=t(f.countText,"Count");M(f.monthNames,12)&&(f.monthNames="Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec".split(" "));M(f.dayNames,7)&&(f.dayNames= +"Mon Tue Wed Thu Fri Sat Sun".split(" "))}function M(a,c){c=N(c)?c:1;return!O(a)||a.length diff --git a/src/heat.js b/src/heat.js index ecc71780..3dce7150 100644 --- a/src/heat.js +++ b/src/heat.js @@ -75,7 +75,7 @@ bindingOptions.element = element; bindingOptions.currentView = {}; bindingOptions.currentView.colorsVisible = {}; - bindingOptions.currentView.year = null; + bindingOptions.currentView.year = bindingOptions.year; bindingOptions.currentView.type = _elements_DateCounts_DefaultType; fireCustomTrigger( bindingOptions.onBeforeRender, element ); @@ -117,10 +117,6 @@ } function renderControlTitleBar( bindingOptions ) { - if ( !isDefinedNumber( bindingOptions.currentView.year ) ) { - bindingOptions.currentView.year = new Date().getFullYear(); - } - if ( bindingOptions.showTitle || bindingOptions.showYearSelector || bindingOptions.showRefreshButton || bindingOptions.showExportButton ) { var titleBar = createElement( "div", "title-bar" ); bindingOptions.element.appendChild( titleBar ); @@ -589,6 +585,7 @@ options.mapTogglesEnabled = getDefaultBoolean( options.mapTogglesEnabled, true ); options.placeMonthNamesOnTheBottom = getDefaultBoolean( options.placeMonthNamesOnTheBottom, false ); options.exportOnlyYearBeingViewed = getDefaultBoolean( options.exportOnlyYearBeingViewed, true ); + options.year = getDefaultNumber( options.year, new Date().getFullYear() ); if ( isInvalidOptionArray( options.monthsToShow ) ) { options.monthsToShow = [ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12 ]; @@ -822,6 +819,10 @@ return isDefinedArray( value ) ? value : defaultValue; } + function getDefaultNumber( value, defaultValue ) { + return isDefinedNumber( value ) ? value : defaultValue; + } + function getDefaultStringOrArray( value, defaultValue ) { if ( isDefinedString( value ) ) { value = value.split( _string.space ); diff --git a/test/dist/heat.js.bootstrap.html b/test/dist/heat.js.bootstrap.html index 04fb1f7f..3df87333 100644 --- a/test/dist/heat.js.bootstrap.html +++ b/test/dist/heat.js.bootstrap.html @@ -20,7 +20,7 @@

Heat.js - Bootstrap



-
+
diff --git a/test/src/heat.js.bootstrap.html b/test/src/heat.js.bootstrap.html index f2733e4c..b206d0a2 100644 --- a/test/src/heat.js.bootstrap.html +++ b/test/src/heat.js.bootstrap.html @@ -20,7 +20,7 @@

Heat.js - Bootstrap



-
+
From 35520e061a47df26ba4112450c36fcd3a027d778 Mon Sep 17 00:00:00 2001 From: William Troup Date: Fri, 19 Jan 2024 17:58:16 +0000 Subject: [PATCH 04/19] Fixed broken documentation links. --- README.md | 4 ++-- README_NUGET.md | 4 ++-- docs/CHANGE_LOG.md | 1 + 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index d64a4420..c41692fc 100644 --- a/README.md +++ b/README.md @@ -96,9 +96,9 @@ Make sure you include the "DOCTYPE html" tag at the top of your HTML, as follows
``` -To see a list of all the available binding options you can use for "data-heat-options", click [here](docs/binding/options/OPTIONS.md). +To see a list of all the available binding options you can use for "data-heat-options", click [here](docs/binding/OPTIONS.md). -To see a list of all the available custom triggers you can use for "data-heat-options", click [here](docs/binding/options/CUSTOM_TRIGGERS.md). +To see a list of all the available custom triggers you can use for "data-heat-options", click [here](docs/binding/CUSTOM_TRIGGERS.md).
diff --git a/README_NUGET.md b/README_NUGET.md index 78faed46..b635b902 100644 --- a/README_NUGET.md +++ b/README_NUGET.md @@ -75,9 +75,9 @@ Make sure you include the "DOCTYPE html" tag at the top of your HTML, as follows ``` -To see a list of all the available binding options you can use for "data-heat-options", click [here](https://github.com/williamtroup/Heat.js/blob/main/docs/binding/options/OPTIONS.md). +To see a list of all the available binding options you can use for "data-heat-options", click [here](https://github.com/williamtroup/Heat.js/blob/main/docs/binding/OPTIONS.md). -To see a list of all the available custom triggers you can use for "data-heat-options", click [here](https://github.com/williamtroup/Heat.js/blob/main/docs/binding/options/CUSTOM_TRIGGERS.md). +To see a list of all the available custom triggers you can use for "data-heat-options", click [here](https://github.com/williamtroup/Heat.js/blob/main/docs/binding/CUSTOM_TRIGGERS.md). ### 4. Adding Dates: diff --git a/docs/CHANGE_LOG.md b/docs/CHANGE_LOG.md index 6f065519..d8689a60 100644 --- a/docs/CHANGE_LOG.md +++ b/docs/CHANGE_LOG.md @@ -7,6 +7,7 @@ #### **Fixes:** - Fixed a fault that prevented decimal values for CSS margins being converted correctly. +- Fixed broken documentation links.
From 4a8a0d9af4b8e8fd87d9fd171163d18c22671774 Mon Sep 17 00:00:00 2001 From: William Troup Date: Fri, 19 Jan 2024 18:00:35 +0000 Subject: [PATCH 05/19] Documentation now points at the website for NuGet. --- README.md | 2 +- README_NUGET.md | 12 ++++++------ 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index c41692fc..e8f1510b 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@ Heat.js [![nuget](https://img.shields.io/badge/nuget-v1.2.0-purple)](https://www.nuget.org/packages/jHeat.js/) [![license](https://img.shields.io/badge/license-MIT-green)](https://github.com/williamtroup/Heat.js/blob/main/LICENSE.txt) [![discussions Welcome](https://img.shields.io/badge/discussions-Welcome-red)](https://github.com/williamtroup/Heat.js/discussions) -[![coded by William Troup](https://img.shields.io/badge/coded_by-William_Troup-yellow)](https://github.com/williamtroup) +[![coded by William Troup](https://img.shields.io/badge/coded_by-William_Troup-yellow)](https://william-troup.com/) >

🌞 A lightweight JavaScript library that generates customizable heat maps to visualize date-based activity and trends.

diff --git a/README_NUGET.md b/README_NUGET.md index b635b902..55e446c1 100644 --- a/README_NUGET.md +++ b/README_NUGET.md @@ -5,7 +5,7 @@ [![nuget](https://img.shields.io/badge/nuget-v1.2.0-purple)](https://www.nuget.org/packages/jHeat.js/) [![license](https://img.shields.io/badge/license-MIT-green)](https://github.com/williamtroup/Heat.js/blob/main/LICENSE.txt) [![discussions Welcome](https://img.shields.io/badge/discussions-Welcome-red)](https://github.com/williamtroup/Heat.js/discussions) -[![coded by William Troup](https://img.shields.io/badge/coded_by-William_Troup-yellow)](https://github.com/williamtroup) +[![coded by William Troup](https://img.shields.io/badge/coded_by-William_Troup-yellow)](https://william-troup.com/) > 🌞 A lightweight JavaScript library that generates customizable heat maps to visualize date-based activity and trends. @@ -45,7 +45,7 @@ All modern browsers (such as Google Chrome, FireFox, and Opera) are fully suppor ## What are the most recent changes? -To see a list of all the most recent changes, click [here](https://github.com/williamtroup/Heat.js/blob/main/docs/CHANGE_LOG.md). +To see a list of all the most recent changes, click [here](https://william-troup.com/heat-js/documentation/recent-changes.html). ## How do I get started? @@ -75,9 +75,9 @@ Make sure you include the "DOCTYPE html" tag at the top of your HTML, as follows ``` -To see a list of all the available binding options you can use for "data-heat-options", click [here](https://github.com/williamtroup/Heat.js/blob/main/docs/binding/OPTIONS.md). +To see a list of all the available binding options you can use for "data-heat-options", click [here](https://william-troup.com/heat-js/documentation/binding-options.html). -To see a list of all the available custom triggers you can use for "data-heat-options", click [here](https://github.com/williamtroup/Heat.js/blob/main/docs/binding/CUSTOM_TRIGGERS.md). +To see a list of all the available custom triggers you can use for "data-heat-options", click [here](https://william-troup.com/heat-js/documentation/binding-options-custom-triggers.html). ### 4. Adding Dates: @@ -106,7 +106,7 @@ To customize, and get more out of Heat.js, please read through the following doc ### 1. Public Functions: -To see a list of all the public functions available, click [here](https://github.com/williamtroup/Heat.js/blob/main/docs/PUBLIC_FUNCTIONS.md). +To see a list of all the public functions available, click [here](https://william-troup.com/heat-js/documentation/public-functions.html). ### 2. Configuration: @@ -121,4 +121,4 @@ Configuration options allow you to customize how Heat.js will function. You can ``` -To see a list of all the available configuration options you can use, click [here](https://github.com/williamtroup/Heat.js/blob/main/docs/OPTIONS.md). \ No newline at end of file +To see a list of all the available configuration options you can use, click [here](https://william-troup.com/heat-js/documentation/options.html). \ No newline at end of file From d1d7814fdc2bd633b6f6d3ced518559534caf382 Mon Sep 17 00:00:00 2001 From: William Troup Date: Fri, 19 Jan 2024 18:04:22 +0000 Subject: [PATCH 06/19] Minor testing file updates. --- test/dist/heat.js.bootstrap.html | 4 +++- test/src/heat.js.bootstrap.html | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/test/dist/heat.js.bootstrap.html b/test/dist/heat.js.bootstrap.html index 3df87333..e2ece2bd 100644 --- a/test/dist/heat.js.bootstrap.html +++ b/test/dist/heat.js.bootstrap.html @@ -20,7 +20,7 @@

Heat.js - Bootstrap



-
+
@@ -59,6 +59,8 @@

Additional Data:

+ + + +
+

Heat.js - Theme

+

This is a basic example of how to use Heat.js to create a basic heatmap using an override theme CSS file.

+
+ +
+
+
+ + + + \ No newline at end of file diff --git a/test/src/heat.js.theme.html b/test/src/heat.js.theme.html new file mode 100644 index 00000000..0ffc9b1b --- /dev/null +++ b/test/src/heat.js.theme.html @@ -0,0 +1,47 @@ + + + + + + Heat.js - Theme + + + + + + + +
+

Heat.js - Theme

+

This is a basic example of how to use Heat.js to create a basic heatmap using an override theme CSS file.

+
+ +
+
+
+ + + + \ No newline at end of file From c3e11dbd2475cc4b74bd22e6a603cb0a8970d736 Mon Sep 17 00:00:00 2001 From: William Troup Date: Fri, 19 Jan 2024 20:50:24 +0000 Subject: [PATCH 18/19] Minor theme improvement. --- dist/themes/heat.js.light.theme.css | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dist/themes/heat.js.light.theme.css b/dist/themes/heat.js.light.theme.css index 6abe37fa..1ffbec45 100644 --- a/dist/themes/heat.js.light.theme.css +++ b/dist/themes/heat.js.light.theme.css @@ -11,7 +11,7 @@ /* Days */ --heat-js-day-background-color: var(--heat-js-color-black); - --heat-js-day-border-color: var(--heat-js-container-border-color); + --heat-js-day-border-color: var(--heat-js-color-gray); --heat-js-day-background-color-hover: var(--heat-js-container-border-color); --heat-js-day-spacing: 6.3px; --heat-js-day-opacity-hover: 0.7; From 2e6a3b7205608e385e44bae59c2d838ad8254798 Mon Sep 17 00:00:00 2001 From: William Troup Date: Fri, 19 Jan 2024 20:52:15 +0000 Subject: [PATCH 19/19] Change log correction. --- docs/CHANGE_LOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/CHANGE_LOG.md b/docs/CHANGE_LOG.md index 33fff52a..c1648259 100644 --- a/docs/CHANGE_LOG.md +++ b/docs/CHANGE_LOG.md @@ -31,7 +31,7 @@ - Removed a large amount of duplicated code. #### **Fixes:** -- Fixed a fault that prevented decimal values for CSS margins being converted correctly. +- Fixed a fault that prevented decimal values for CSS margins from being converted correctly. - Fixed broken documentation links.