Skip to content

Commit 80390c7

Browse files
committed
[Heatmap] Localize Tooltip Dates
1 parent af9c541 commit 80390c7

File tree

1 file changed

+43
-0
lines changed

1 file changed

+43
-0
lines changed

dist/frappe-charts.esm.js

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ function $(expr, con) {
22
return typeof expr === "string"? (con || document).querySelector(expr) : expr || null;
33
}
44

5+
6+
57
$.create = (tag, o) => {
68
var element = document.createElement(tag);
79

@@ -64,6 +66,10 @@ function getElementContentWidth(element) {
6466
return element.clientWidth - padding;
6567
}
6668

69+
70+
71+
72+
6773
function fire(target, type, properties) {
6874
var evt = document.createEvent("HTMLEvents");
6975

@@ -76,6 +82,8 @@ function fire(target, type, properties) {
7682
return target.dispatchEvent(evt);
7783
}
7884

85+
// https://css-tricks.com/snippets/javascript/loop-queryselectorall-matches/
86+
7987
const BASE_MEASURES = {
8088
margins: {
8189
top: 10,
@@ -151,6 +159,8 @@ const DEFAULT_CHART_COLORS = ['light-blue', 'blue', 'violet', 'red', 'orange',
151159
'yellow', 'green', 'light-green', 'purple', 'magenta', 'light-grey', 'dark-grey'];
152160
const HEATMAP_COLORS_GREEN = ['#ebedf0', '#c6e48b', '#7bc96f', '#239a3b', '#196127'];
153161

162+
163+
154164
const DEFAULT_COLORS = {
155165
bar: DEFAULT_CHART_COLORS,
156166
line: DEFAULT_CHART_COLORS,
@@ -292,6 +302,19 @@ function floatTwo(d) {
292302
return parseFloat(d.toFixed(2));
293303
}
294304

305+
/**
306+
* Returns whether or not two given arrays are equal.
307+
* @param {Array} arr1 First array
308+
* @param {Array} arr2 Second array
309+
*/
310+
311+
312+
/**
313+
* Shuffles array in place. ES6 version
314+
* @param {Array} array An array containing the items.
315+
*/
316+
317+
295318
/**
296319
* Fill an array with extra points
297320
* @param {Array} array Array
@@ -317,6 +340,11 @@ function getStringWidth(string, charWidth) {
317340
return (string+"").length * charWidth;
318341
}
319342

343+
344+
345+
// https://stackoverflow.com/a/29325222
346+
347+
320348
function getPositionByAngle(angle, radius) {
321349
return {
322350
x: Math.sin(angle * ANGLE_RATIO) * radius,
@@ -482,6 +510,8 @@ function makeSVGGroup(className, transform='', parent=undefined) {
482510
return createSVG('g', args);
483511
}
484512

513+
514+
485515
function makePath(pathStr, className='', stroke='none', fill='none') {
486516
return createSVG('path', {
487517
className: className,
@@ -1703,14 +1733,17 @@ class AggregationChart extends BaseChart {
17031733

17041734
const NO_OF_YEAR_MONTHS = 12;
17051735
const NO_OF_DAYS_IN_WEEK = 7;
1736+
17061737
const NO_OF_MILLIS = 1000;
17071738
const SEC_IN_DAY = 86400;
17081739

17091740
const MONTH_NAMES = ["January", "February", "March", "April", "May",
17101741
"June", "July", "August", "September", "October", "November", "December"];
17111742

1743+
17121744
const DAY_NAMES_SHORT = ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"];
17131745

1746+
17141747
// https://stackoverflow.com/a/11252167/6495043
17151748
function treatAsUtc(date) {
17161749
let result = new Date(date);
@@ -1732,6 +1765,10 @@ function clone(date) {
17321765
return new Date(date.getTime());
17331766
}
17341767

1768+
1769+
1770+
1771+
17351772
// export function getMonthsBetween(startDate, endDate) {}
17361773

17371774
function getWeeksBetween(startDate, endDate) {
@@ -2606,6 +2643,8 @@ function getZeroIndex(yPts) {
26062643
return zeroIndex;
26072644
}
26082645

2646+
2647+
26092648
function getIntervalSize(orderedArray) {
26102649
return orderedArray[1] - orderedArray[0];
26112650
}
@@ -2618,6 +2657,10 @@ function scale(val, yAxis) {
26182657
return floatTwo(yAxis.zeroLine - val * yAxis.scaleMultiplier);
26192658
}
26202659

2660+
2661+
2662+
2663+
26212664
function getClosestInArray(goal, arr, index = false) {
26222665
let closest = arr.reduce(function(prev, curr) {
26232666
return (Math.abs(curr - goal) < Math.abs(prev - goal) ? curr : prev);

0 commit comments

Comments
 (0)