Skip to content

Commit

Permalink
[Heatmap] Localize Tooltip Dates
Browse files Browse the repository at this point in the history
  • Loading branch information
kimili committed Apr 23, 2018
1 parent af9c541 commit 80390c7
Showing 1 changed file with 43 additions and 0 deletions.
43 changes: 43 additions & 0 deletions dist/frappe-charts.esm.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ function $(expr, con) {
return typeof expr === "string"? (con || document).querySelector(expr) : expr || null;
}



$.create = (tag, o) => {
var element = document.createElement(tag);

Expand Down Expand Up @@ -64,6 +66,10 @@ function getElementContentWidth(element) {
return element.clientWidth - padding;
}





function fire(target, type, properties) {
var evt = document.createEvent("HTMLEvents");

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

// https://css-tricks.com/snippets/javascript/loop-queryselectorall-matches/

const BASE_MEASURES = {
margins: {
top: 10,
Expand Down Expand Up @@ -151,6 +159,8 @@ const DEFAULT_CHART_COLORS = ['light-blue', 'blue', 'violet', 'red', 'orange',
'yellow', 'green', 'light-green', 'purple', 'magenta', 'light-grey', 'dark-grey'];
const HEATMAP_COLORS_GREEN = ['#ebedf0', '#c6e48b', '#7bc96f', '#239a3b', '#196127'];



const DEFAULT_COLORS = {
bar: DEFAULT_CHART_COLORS,
line: DEFAULT_CHART_COLORS,
Expand Down Expand Up @@ -292,6 +302,19 @@ function floatTwo(d) {
return parseFloat(d.toFixed(2));
}

/**
* Returns whether or not two given arrays are equal.
* @param {Array} arr1 First array
* @param {Array} arr2 Second array
*/


/**
* Shuffles array in place. ES6 version
* @param {Array} array An array containing the items.
*/


/**
* Fill an array with extra points
* @param {Array} array Array
Expand All @@ -317,6 +340,11 @@ function getStringWidth(string, charWidth) {
return (string+"").length * charWidth;
}



// https://stackoverflow.com/a/29325222


function getPositionByAngle(angle, radius) {
return {
x: Math.sin(angle * ANGLE_RATIO) * radius,
Expand Down Expand Up @@ -482,6 +510,8 @@ function makeSVGGroup(className, transform='', parent=undefined) {
return createSVG('g', args);
}



function makePath(pathStr, className='', stroke='none', fill='none') {
return createSVG('path', {
className: className,
Expand Down Expand Up @@ -1703,14 +1733,17 @@ class AggregationChart extends BaseChart {

const NO_OF_YEAR_MONTHS = 12;
const NO_OF_DAYS_IN_WEEK = 7;

const NO_OF_MILLIS = 1000;
const SEC_IN_DAY = 86400;

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


const DAY_NAMES_SHORT = ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"];


// https://stackoverflow.com/a/11252167/6495043
function treatAsUtc(date) {
let result = new Date(date);
Expand All @@ -1732,6 +1765,10 @@ function clone(date) {
return new Date(date.getTime());
}





// export function getMonthsBetween(startDate, endDate) {}

function getWeeksBetween(startDate, endDate) {
Expand Down Expand Up @@ -2606,6 +2643,8 @@ function getZeroIndex(yPts) {
return zeroIndex;
}



function getIntervalSize(orderedArray) {
return orderedArray[1] - orderedArray[0];
}
Expand All @@ -2618,6 +2657,10 @@ function scale(val, yAxis) {
return floatTwo(yAxis.zeroLine - val * yAxis.scaleMultiplier);
}





function getClosestInArray(goal, arr, index = false) {
let closest = arr.reduce(function(prev, curr) {
return (Math.abs(curr - goal) < Math.abs(prev - goal) ? curr : prev);
Expand Down

0 comments on commit 80390c7

Please sign in to comment.