inviton-powerduck 0.0.153 → 0.0.155
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/app/powerduck-initializer.ts +3 -3
- package/common/api-http.ts +20 -14
- package/common/css/ladda-themeless-zoomin.min.css +89 -89
- package/common/enum-translation/day-translator.ts +3 -2
- package/common/excel/excel-reader.ts +2 -9
- package/common/extensions/array-extensions.ts +116 -0
- package/common/extensions/string-extensions.ts +92 -0
- package/common/extensions/temporal-extensions.ts +115 -0
- package/common/scroll-utils.ts +2 -1
- package/common/temporal-helpers.ts +551 -0
- package/common/throttled-api-caller.ts +149 -0
- package/common/timezone-helper.ts +39 -29
- package/common/utils/cookie.ts +11 -8
- package/common/utils/date-localization-utils.ts +25 -19
- package/common/utils/date-utils.ts +37 -47
- package/common/utils/form-utils.ts +3 -1
- package/common/utils/language-utils.ts +21 -27
- package/common/utils/temporal-utils.ts +43 -0
- package/common/utils/upload-image-helper.ts +1 -1
- package/common/utils/utils.ts +14 -14
- package/common/validation.ts +17 -5
- package/components/chart-js/line-chart-flot.tsx +9 -9
- package/components/chart-js/thirdparty/flot/jquery.flot.categories.min.js +93 -93
- package/components/chart-js/thirdparty/flot/jquery.flot.crosshair.min.js +83 -83
- package/components/chart-js/thirdparty/flot/jquery.flot.navigate.min.js +270 -270
- package/components/chart-js/thirdparty/flot/jquery.flot.pie.min.js +507 -507
- package/components/chart-js/thirdparty/flot/jquery.flot.resize.js +7 -9
- package/components/chart-js/thirdparty/flot/jquery.flot.resize.min.js +9 -11
- package/components/chart-js/thirdparty/flot/jquery.flot.stack.min.js +104 -104
- package/components/chart-js/ts/line-chart-contracts.ts +2 -2
- package/components/container-with-breakpoints/ts/breakpoint-handler.ts +2 -2
- package/components/counter/testall.tsx +89 -75
- package/components/datatable/datatable.tsx +2379 -2375
- package/components/datatable/export-excel-modal.tsx +12 -14
- package/components/datatable/ts/reorder.ts +4 -2
- package/components/dropdown/index.tsx +48 -22
- package/components/dropdown/mobile/legacy_fdd.ts +10 -11
- package/components/dropzone/gallery-dropzone.tsx +394 -382
- package/components/fullcalendar/fullcalendar-draggable-event.tsx +8 -7
- package/components/fullcalendar/timegrid-calendar.tsx +60 -67
- package/components/image-crop/image-cropping-modal.tsx +9 -8
- package/components/image-crop/upload-and-crop.tsx +162 -162
- package/components/image-crop/vendor/jquery.Jcrop.min.css +344 -344
- package/components/import/import-mapper.tsx +2 -2
- package/components/input/daterange-picker.tsx +502 -521
- package/components/input/datetime-picker.tsx +45 -50
- package/components/input/plugins/daterangepicker/daterangepicker.min.css +400 -400
- package/components/input/plugins/daterangepicker/jquery.daterangepicker.min.js +346 -339
- package/components/input/plugins/daterangepicker/jquery.daterangepicker.ts +580 -402
- package/components/input/radio-button-group.tsx +2 -2
- package/components/input/ts/dateInputHelper.ts +1 -0
- package/components/input/wysiwig.tsx +12 -7
- package/components/svg/skilift-svg.tsx +6 -6
- package/package.json +2 -1
- package/common/date-wrapper.ts +0 -422
- package/common/utils/array-extend.ts +0 -215
- package/common/utils/array-remove.ts +0 -10
- package/common/utils/array-sort.ts +0 -56
- package/common/utils/capitalize-string.ts +0 -11
- package/common/utils/format-string.ts +0 -14
- package/common/utils/latinize-string.ts +0 -7
package/common/utils/utils.ts
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import PowerduckState from '../../app/powerduck-state';
|
|
2
|
-
import { latinize } from '
|
|
2
|
+
import { latinize } from '../extensions/string-extensions';
|
|
3
|
+
import TemporalUtils from './temporal-utils';
|
|
3
4
|
|
|
4
5
|
export class PortalUtils {
|
|
5
6
|
private static _isTouchDeviceVal: boolean;
|
|
6
|
-
private static _isChromeBrowser: boolean
|
|
7
|
-
private static _treatAsMobileDeviceVal: boolean
|
|
7
|
+
private static _isChromeBrowser: boolean;
|
|
8
|
+
private static _treatAsMobileDeviceVal: boolean;
|
|
8
9
|
|
|
9
10
|
/**
|
|
10
11
|
* Gets if current site is run inside an iframe
|
|
@@ -21,9 +22,7 @@ export class PortalUtils {
|
|
|
21
22
|
* Determines if current device runs iOS
|
|
22
23
|
*/
|
|
23
24
|
static isIOS(): boolean {
|
|
24
|
-
return (
|
|
25
|
-
(/iPad|iPhone|iPod/.test(navigator.userAgent) && !(window as any).MSStream) || navigator.userAgent.match(/(iPad)/) != null || (navigator.platform === 'MacIntel' && navigator.maxTouchPoints > 1)
|
|
26
|
-
);
|
|
25
|
+
return ((/iPad|iPhone|iPod/.test(navigator.userAgent) && !(window as any).MSStream) || navigator.userAgent.match(/(iPad)/) != null || (navigator.platform === 'MacIntel' && navigator.maxTouchPoints > 1));
|
|
27
26
|
}
|
|
28
27
|
|
|
29
28
|
/**
|
|
@@ -78,7 +77,7 @@ export class PortalUtils {
|
|
|
78
77
|
* Performs normalization / unification for search
|
|
79
78
|
*/
|
|
80
79
|
static normalizeStringForSearch(str: string): string {
|
|
81
|
-
return
|
|
80
|
+
return str.toLowerCase()[latinize]().trim();
|
|
82
81
|
}
|
|
83
82
|
|
|
84
83
|
/**
|
|
@@ -145,8 +144,8 @@ export class PortalUtils {
|
|
|
145
144
|
}
|
|
146
145
|
|
|
147
146
|
/*
|
|
148
|
-
|
|
149
|
-
|
|
147
|
+
* Obtains URL for asset either on CDN, or on local
|
|
148
|
+
*/
|
|
150
149
|
static getAssetPath(path: string): string {
|
|
151
150
|
return PowerduckState.getCdnPath() + path;
|
|
152
151
|
}
|
|
@@ -283,7 +282,7 @@ export class PortalUtils {
|
|
|
283
282
|
* Recursively climbs UP the tree to determine first PARENT node of the scroll element to obtain the scroll target
|
|
284
283
|
* @param currentElem
|
|
285
284
|
*/
|
|
286
|
-
|
|
285
|
+
const getScrollTaget = (currentElem: HTMLElement): HTMLElement => {
|
|
287
286
|
if (
|
|
288
287
|
currentElem.scrollTop != 0
|
|
289
288
|
|| currentElem.nodeName == 'DIALOG'
|
|
@@ -297,7 +296,7 @@ export class PortalUtils {
|
|
|
297
296
|
} else {
|
|
298
297
|
return getScrollTaget(currentElem.parentElement);
|
|
299
298
|
}
|
|
300
|
-
}
|
|
299
|
+
};
|
|
301
300
|
|
|
302
301
|
const scrollElem = getScrollTaget(<HTMLElement>element);
|
|
303
302
|
const target = (<HTMLElement>element).getBoundingClientRect().top + scrollElem.scrollTop + (offset != null ? offset : 0);
|
|
@@ -312,7 +311,7 @@ export class PortalUtils {
|
|
|
312
311
|
* Recursively climbs DOWN the tree to determine first CHILD node of the scroll element to obtain the scroll target
|
|
313
312
|
* @param currentElem
|
|
314
313
|
*/
|
|
315
|
-
|
|
314
|
+
const getScrollTaget = (currentElem: HTMLElement): HTMLElement => {
|
|
316
315
|
if (currentElem.scrollTop != 0) {
|
|
317
316
|
return currentElem;
|
|
318
317
|
}
|
|
@@ -330,7 +329,7 @@ export class PortalUtils {
|
|
|
330
329
|
}
|
|
331
330
|
|
|
332
331
|
return null;
|
|
333
|
-
}
|
|
332
|
+
};
|
|
334
333
|
|
|
335
334
|
PortalUtils.scrollElement(getScrollTaget(document.body) || document.body.parentElement, 0);
|
|
336
335
|
}
|
|
@@ -400,6 +399,7 @@ export class PortalUtils {
|
|
|
400
399
|
} else {
|
|
401
400
|
arr = [];
|
|
402
401
|
for (const key in fieldArr) {
|
|
402
|
+
// eslint-disable-next-line no-prototype-builtins
|
|
403
403
|
if (fieldArr.hasOwnProperty(key)) {
|
|
404
404
|
arr.push({
|
|
405
405
|
name: key,
|
|
@@ -410,7 +410,7 @@ export class PortalUtils {
|
|
|
410
410
|
}
|
|
411
411
|
|
|
412
412
|
const formMethod = 'POST';
|
|
413
|
-
const formName = `frm${
|
|
413
|
+
const formName = `frm${TemporalUtils.dateNowMs()}`;
|
|
414
414
|
let newForm = `<form id="${formName}" method="${formMethod}" action="${url}" target="_blank">`;
|
|
415
415
|
|
|
416
416
|
$.each(arr, (i, field) => {
|
package/common/validation.ts
CHANGED
|
@@ -23,10 +23,10 @@ import {
|
|
|
23
23
|
} from '@vuelidate/validators';
|
|
24
24
|
import PowerduckState from '../app/powerduck-state';
|
|
25
25
|
import LocalizedValueHelper from './localized-value-helper';
|
|
26
|
-
import { capitalize } from './utils/capitalize-string';
|
|
27
26
|
import { isNullOrEmpty } from './utils/is-null-or-empty';
|
|
27
|
+
import { capitalize } from './extensions/string-extensions';
|
|
28
28
|
|
|
29
|
-
const getFirstUnsattisfiedValidatorName = (valProp: Validation): string => {
|
|
29
|
+
const getFirstUnsattisfiedValidatorName = (valProp: Validation): string | null => {
|
|
30
30
|
const errors = valProp?.$errors || [];
|
|
31
31
|
for (const fieldError of errors) {
|
|
32
32
|
if (fieldError != null) {
|
|
@@ -37,16 +37,16 @@ const getFirstUnsattisfiedValidatorName = (valProp: Validation): string => {
|
|
|
37
37
|
return null;
|
|
38
38
|
};
|
|
39
39
|
|
|
40
|
-
const getErrorMessage = (valProp: Validation, invalidValidatorName: string): string => {
|
|
40
|
+
const getErrorMessage = (valProp: Validation, invalidValidatorName: string): string | null => {
|
|
41
41
|
if (invalidValidatorName == null) {
|
|
42
42
|
return null;
|
|
43
43
|
}
|
|
44
44
|
|
|
45
|
-
if (invalidValidatorName == 'requiredIf' || invalidValidatorName == 'requiredLocalizedString') {
|
|
45
|
+
if (invalidValidatorName == 'requiredIf' || invalidValidatorName == 'requiredLocalizedString' || invalidValidatorName == 'requiredTemporal') {
|
|
46
46
|
invalidValidatorName = 'required';
|
|
47
47
|
}
|
|
48
48
|
|
|
49
|
-
let errMsg = PowerduckState.getResourceValue(`validationError${capitalize(
|
|
49
|
+
let errMsg = PowerduckState.getResourceValue(`validationError${invalidValidatorName[capitalize]()}` as any);
|
|
50
50
|
switch (invalidValidatorName) {
|
|
51
51
|
case 'minLength':
|
|
52
52
|
case 'minValue':
|
|
@@ -167,6 +167,18 @@ export class ValidationBuilder {
|
|
|
167
167
|
return this;
|
|
168
168
|
}
|
|
169
169
|
|
|
170
|
+
requiredTemporal(): ValidationBuilder {
|
|
171
|
+
this._validationArgs.requiredTemporal = (value) => {
|
|
172
|
+
if (value === null || !value || typeof value !== 'object') {
|
|
173
|
+
return false;
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
return true;
|
|
177
|
+
};
|
|
178
|
+
|
|
179
|
+
return this;
|
|
180
|
+
}
|
|
181
|
+
|
|
170
182
|
requiredUnless?(field: string | ((vm: any, parentVm?: PowerduckViewModelBase) => any)): ValidationBuilder {
|
|
171
183
|
this._validationArgs.requiredUnless = requiredUnless(field as string);
|
|
172
184
|
return this;
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { Temporal } from '@js-temporal/polyfill';
|
|
2
2
|
import type { LineChartArgs, LineChartDataArgs } from './ts/line-chart-contracts';
|
|
3
3
|
import { Prop, toNative } from 'vue-facing-decorator';
|
|
4
|
-
import TsxComponent, { Component } from '../../app/vuetsx';
|
|
5
4
|
|
|
5
|
+
import TsxComponent, { Component } from '../../app/vuetsx';
|
|
6
|
+
import { toDisplayString } from '../../common/extensions/temporal-extensions';
|
|
6
7
|
import { isNullOrEmpty } from '../../common/utils/is-null-or-empty';
|
|
7
8
|
import { PortalUtils } from '../../common/utils/utils';
|
|
8
9
|
import arrowBottomIcon from './img/arrow-down.gif';
|
|
@@ -11,9 +12,9 @@ import arrowRightIcon from './img/arrow-right.gif';
|
|
|
11
12
|
import arrowTopIcon from './img/arrow-up.gif';
|
|
12
13
|
import './thirdparty/flot/jquery.flot-patched.js';
|
|
13
14
|
import './thirdparty/flot/jquery.flot.pie.js';
|
|
15
|
+
|
|
14
16
|
import './thirdparty/flot/jquery.flot.stack.js';
|
|
15
17
|
import './thirdparty/flot/jquery.flot.crosshair.js';
|
|
16
|
-
|
|
17
18
|
import './thirdparty/flot/jquery.flot.resize.js';
|
|
18
19
|
import './thirdparty/flot/jquery.flot.categories.js';
|
|
19
20
|
import './thirdparty/flot/jquery.flot.navigate.js';
|
|
@@ -61,7 +62,6 @@ class LineChartFlotComponent extends TsxComponent<LineChartArgs> implements Line
|
|
|
61
62
|
const itemData = [];
|
|
62
63
|
const performCreation = true;
|
|
63
64
|
let hasData = false;
|
|
64
|
-
const self = this;
|
|
65
65
|
|
|
66
66
|
if (dataParam != null && dataParam.length > 0) {
|
|
67
67
|
dataParam.forEach((currItem) => {
|
|
@@ -78,7 +78,7 @@ class LineChartFlotComponent extends TsxComponent<LineChartArgs> implements Line
|
|
|
78
78
|
|
|
79
79
|
ciData.forEach((dataItem) => {
|
|
80
80
|
dataArr.push([
|
|
81
|
-
PortalUtils.isString(dataItem.caption) ? dataItem.caption : (dataItem.caption as
|
|
81
|
+
PortalUtils.isString(dataItem.caption) ? dataItem.caption : (dataItem.caption as Temporal.PlainDateTime)[toDisplayString](true),
|
|
82
82
|
Math.max(dataItem.value, 0),
|
|
83
83
|
dataItem.tooltipSuffix,
|
|
84
84
|
dataItem.uuid,
|
|
@@ -281,8 +281,8 @@ class LineChartFlotComponent extends TsxComponent<LineChartArgs> implements Line
|
|
|
281
281
|
item,
|
|
282
282
|
) => {
|
|
283
283
|
if (dataParam.length == 1) {
|
|
284
|
-
if (item &&
|
|
285
|
-
|
|
284
|
+
if (item && this.itemClicked != null) {
|
|
285
|
+
this.itemClicked(item.series.data[item.dataIndex][3]);
|
|
286
286
|
}
|
|
287
287
|
}
|
|
288
288
|
});
|
|
@@ -295,8 +295,8 @@ class LineChartFlotComponent extends TsxComponent<LineChartArgs> implements Line
|
|
|
295
295
|
offset,
|
|
296
296
|
) => {
|
|
297
297
|
$(`<img class="plot-button" src="${icon}" style="position: absolute;cursor: pointer;right:${right
|
|
298
|
-
|
|
299
|
-
|
|
298
|
+
}px;top:${top
|
|
299
|
+
}px">`)
|
|
300
300
|
.appendTo(elem)
|
|
301
301
|
.click((e) => {
|
|
302
302
|
e.preventDefault();
|
|
@@ -1,93 +1,93 @@
|
|
|
1
|
-
/* Javascript plotting library for jQuery, version 0.8.3.
|
|
2
|
-
|
|
3
|
-
Copyright (c) 2007-2014 IOLA and Ole Laursen.
|
|
4
|
-
Licensed under the MIT license.
|
|
5
|
-
|
|
6
|
-
*/
|
|
7
|
-
(function ($) {
|
|
8
|
-
var options = { xaxis: { categories: null }, yaxis: { categories: null } };
|
|
9
|
-
function processRawData(plot, series, data, datapoints) {
|
|
10
|
-
var xCategories = series.xaxis.options.mode == "categories",
|
|
11
|
-
yCategories = series.yaxis.options.mode == "categories";
|
|
12
|
-
if (!(xCategories || yCategories)) return;
|
|
13
|
-
var format = datapoints.format;
|
|
14
|
-
if (!format) {
|
|
15
|
-
var s = series;
|
|
16
|
-
format = [];
|
|
17
|
-
format.push({ x: true, number: true, required: true });
|
|
18
|
-
format.push({ y: true, number: true, required: true });
|
|
19
|
-
if (s.bars.show || (s.lines.show && s.lines.fill)) {
|
|
20
|
-
var autoscale = !!((s.bars.show && s.bars.zero) || (s.lines.show && s.lines.zero));
|
|
21
|
-
format.push({ y: true, number: true, required: false, defaultValue: 0, autoscale: autoscale });
|
|
22
|
-
if (s.bars.horizontal) {
|
|
23
|
-
delete format[format.length - 1].y;
|
|
24
|
-
format[format.length - 1].x = true;
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
datapoints.format = format;
|
|
28
|
-
}
|
|
29
|
-
for (var m = 0; m < format.length; ++m) {
|
|
30
|
-
if (format[m].x && xCategories) format[m].number = false;
|
|
31
|
-
if (format[m].y && yCategories) format[m].number = false;
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
function getNextIndex(categories) {
|
|
35
|
-
var index = -1;
|
|
36
|
-
for (var v in categories) if (categories[v] > index) index = categories[v];
|
|
37
|
-
return index + 1;
|
|
38
|
-
}
|
|
39
|
-
function categoriesTickGenerator(axis) {
|
|
40
|
-
var res = [];
|
|
41
|
-
for (var label in axis.categories) {
|
|
42
|
-
var v = axis.categories[label];
|
|
43
|
-
if (v >= axis.min && v <= axis.max) res.push([v, label]);
|
|
44
|
-
}
|
|
45
|
-
res.sort(function (a, b) {
|
|
46
|
-
return a[0] - b[0];
|
|
47
|
-
});
|
|
48
|
-
return res;
|
|
49
|
-
}
|
|
50
|
-
function setupCategoriesForAxis(series, axis, datapoints) {
|
|
51
|
-
if (series[axis].options.mode != "categories") return;
|
|
52
|
-
if (!series[axis].categories) {
|
|
53
|
-
var c = {},
|
|
54
|
-
o = series[axis].options.categories || {};
|
|
55
|
-
if ($.isArray(o)) {
|
|
56
|
-
for (var i = 0; i < o.length; ++i) c[o[i]] = i;
|
|
57
|
-
} else {
|
|
58
|
-
for (var v in o) c[v] = o[v];
|
|
59
|
-
}
|
|
60
|
-
series[axis].categories = c;
|
|
61
|
-
}
|
|
62
|
-
if (!series[axis].options.ticks) series[axis].options.ticks = categoriesTickGenerator;
|
|
63
|
-
transformPointsOnAxis(datapoints, axis, series[axis].categories);
|
|
64
|
-
}
|
|
65
|
-
function transformPointsOnAxis(datapoints, axis, categories) {
|
|
66
|
-
var points = datapoints.points,
|
|
67
|
-
ps = datapoints.pointsize,
|
|
68
|
-
format = datapoints.format,
|
|
69
|
-
formatColumn = axis.charAt(0),
|
|
70
|
-
index = getNextIndex(categories);
|
|
71
|
-
for (var i = 0; i < points.length; i += ps) {
|
|
72
|
-
if (points[i] == null) continue;
|
|
73
|
-
for (var m = 0; m < ps; ++m) {
|
|
74
|
-
var val = points[i + m];
|
|
75
|
-
if (val == null || !format[m][formatColumn]) continue;
|
|
76
|
-
if (!(val in categories)) {
|
|
77
|
-
categories[val] = index;
|
|
78
|
-
++index;
|
|
79
|
-
}
|
|
80
|
-
points[i + m] = categories[val];
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
}
|
|
84
|
-
function processDatapoints(plot, series, datapoints) {
|
|
85
|
-
setupCategoriesForAxis(series, "xaxis", datapoints);
|
|
86
|
-
setupCategoriesForAxis(series, "yaxis", datapoints);
|
|
87
|
-
}
|
|
88
|
-
function init(plot) {
|
|
89
|
-
plot.hooks.processRawData.push(processRawData);
|
|
90
|
-
plot.hooks.processDatapoints.push(processDatapoints);
|
|
91
|
-
}
|
|
92
|
-
$.plot.plugins.push({ init: init, options: options, name: "categories", version: "1.0" });
|
|
93
|
-
})(jQuery);
|
|
1
|
+
/* Javascript plotting library for jQuery, version 0.8.3.
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2007-2014 IOLA and Ole Laursen.
|
|
4
|
+
Licensed under the MIT license.
|
|
5
|
+
|
|
6
|
+
*/
|
|
7
|
+
(function ($) {
|
|
8
|
+
var options = { xaxis: { categories: null }, yaxis: { categories: null } };
|
|
9
|
+
function processRawData(plot, series, data, datapoints) {
|
|
10
|
+
var xCategories = series.xaxis.options.mode == "categories",
|
|
11
|
+
yCategories = series.yaxis.options.mode == "categories";
|
|
12
|
+
if (!(xCategories || yCategories)) return;
|
|
13
|
+
var format = datapoints.format;
|
|
14
|
+
if (!format) {
|
|
15
|
+
var s = series;
|
|
16
|
+
format = [];
|
|
17
|
+
format.push({ x: true, number: true, required: true });
|
|
18
|
+
format.push({ y: true, number: true, required: true });
|
|
19
|
+
if (s.bars.show || (s.lines.show && s.lines.fill)) {
|
|
20
|
+
var autoscale = !!((s.bars.show && s.bars.zero) || (s.lines.show && s.lines.zero));
|
|
21
|
+
format.push({ y: true, number: true, required: false, defaultValue: 0, autoscale: autoscale });
|
|
22
|
+
if (s.bars.horizontal) {
|
|
23
|
+
delete format[format.length - 1].y;
|
|
24
|
+
format[format.length - 1].x = true;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
datapoints.format = format;
|
|
28
|
+
}
|
|
29
|
+
for (var m = 0; m < format.length; ++m) {
|
|
30
|
+
if (format[m].x && xCategories) format[m].number = false;
|
|
31
|
+
if (format[m].y && yCategories) format[m].number = false;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
function getNextIndex(categories) {
|
|
35
|
+
var index = -1;
|
|
36
|
+
for (var v in categories) if (categories[v] > index) index = categories[v];
|
|
37
|
+
return index + 1;
|
|
38
|
+
}
|
|
39
|
+
function categoriesTickGenerator(axis) {
|
|
40
|
+
var res = [];
|
|
41
|
+
for (var label in axis.categories) {
|
|
42
|
+
var v = axis.categories[label];
|
|
43
|
+
if (v >= axis.min && v <= axis.max) res.push([v, label]);
|
|
44
|
+
}
|
|
45
|
+
res.sort(function (a, b) {
|
|
46
|
+
return a[0] - b[0];
|
|
47
|
+
});
|
|
48
|
+
return res;
|
|
49
|
+
}
|
|
50
|
+
function setupCategoriesForAxis(series, axis, datapoints) {
|
|
51
|
+
if (series[axis].options.mode != "categories") return;
|
|
52
|
+
if (!series[axis].categories) {
|
|
53
|
+
var c = {},
|
|
54
|
+
o = series[axis].options.categories || {};
|
|
55
|
+
if ($.isArray(o)) {
|
|
56
|
+
for (var i = 0; i < o.length; ++i) c[o[i]] = i;
|
|
57
|
+
} else {
|
|
58
|
+
for (var v in o) c[v] = o[v];
|
|
59
|
+
}
|
|
60
|
+
series[axis].categories = c;
|
|
61
|
+
}
|
|
62
|
+
if (!series[axis].options.ticks) series[axis].options.ticks = categoriesTickGenerator;
|
|
63
|
+
transformPointsOnAxis(datapoints, axis, series[axis].categories);
|
|
64
|
+
}
|
|
65
|
+
function transformPointsOnAxis(datapoints, axis, categories) {
|
|
66
|
+
var points = datapoints.points,
|
|
67
|
+
ps = datapoints.pointsize,
|
|
68
|
+
format = datapoints.format,
|
|
69
|
+
formatColumn = axis.charAt(0),
|
|
70
|
+
index = getNextIndex(categories);
|
|
71
|
+
for (var i = 0; i < points.length; i += ps) {
|
|
72
|
+
if (points[i] == null) continue;
|
|
73
|
+
for (var m = 0; m < ps; ++m) {
|
|
74
|
+
var val = points[i + m];
|
|
75
|
+
if (val == null || !format[m][formatColumn]) continue;
|
|
76
|
+
if (!(val in categories)) {
|
|
77
|
+
categories[val] = index;
|
|
78
|
+
++index;
|
|
79
|
+
}
|
|
80
|
+
points[i + m] = categories[val];
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
function processDatapoints(plot, series, datapoints) {
|
|
85
|
+
setupCategoriesForAxis(series, "xaxis", datapoints);
|
|
86
|
+
setupCategoriesForAxis(series, "yaxis", datapoints);
|
|
87
|
+
}
|
|
88
|
+
function init(plot) {
|
|
89
|
+
plot.hooks.processRawData.push(processRawData);
|
|
90
|
+
plot.hooks.processDatapoints.push(processDatapoints);
|
|
91
|
+
}
|
|
92
|
+
$.plot.plugins.push({ init: init, options: options, name: "categories", version: "1.0" });
|
|
93
|
+
})(jQuery);
|
|
@@ -1,83 +1,83 @@
|
|
|
1
|
-
/* Javascript plotting library for jQuery, version 0.8.3.
|
|
2
|
-
|
|
3
|
-
Copyright (c) 2007-2014 IOLA and Ole Laursen.
|
|
4
|
-
Licensed under the MIT license.
|
|
5
|
-
|
|
6
|
-
*/
|
|
7
|
-
(function ($) {
|
|
8
|
-
var options = { crosshair: { mode: null, color: "rgba(170, 0, 0, 0.80)", lineWidth: 1 } };
|
|
9
|
-
function init(plot) {
|
|
10
|
-
var crosshair = { x: -1, y: -1, locked: false };
|
|
11
|
-
plot.setCrosshair = function setCrosshair(pos) {
|
|
12
|
-
if (!pos) crosshair.x = -1;
|
|
13
|
-
else {
|
|
14
|
-
var o = plot.p2c(pos);
|
|
15
|
-
crosshair.x = Math.max(0, Math.min(o.left, plot.width()));
|
|
16
|
-
crosshair.y = Math.max(0, Math.min(o.top, plot.height()));
|
|
17
|
-
}
|
|
18
|
-
plot.triggerRedrawOverlay();
|
|
19
|
-
};
|
|
20
|
-
plot.clearCrosshair = plot.setCrosshair;
|
|
21
|
-
plot.lockCrosshair = function lockCrosshair(pos) {
|
|
22
|
-
if (pos) plot.setCrosshair(pos);
|
|
23
|
-
crosshair.locked = true;
|
|
24
|
-
};
|
|
25
|
-
plot.unlockCrosshair = function unlockCrosshair() {
|
|
26
|
-
crosshair.locked = false;
|
|
27
|
-
};
|
|
28
|
-
function onMouseOut(e) {
|
|
29
|
-
if (crosshair.locked) return;
|
|
30
|
-
if (crosshair.x != -1) {
|
|
31
|
-
crosshair.x = -1;
|
|
32
|
-
plot.triggerRedrawOverlay();
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
function onMouseMove(e) {
|
|
36
|
-
if (crosshair.locked) return;
|
|
37
|
-
if (plot.getSelection && plot.getSelection()) {
|
|
38
|
-
crosshair.x = -1;
|
|
39
|
-
return;
|
|
40
|
-
}
|
|
41
|
-
var offset = plot.offset();
|
|
42
|
-
crosshair.x = Math.max(0, Math.min(e.pageX - offset.left, plot.width()));
|
|
43
|
-
crosshair.y = Math.max(0, Math.min(e.pageY - offset.top, plot.height()));
|
|
44
|
-
plot.triggerRedrawOverlay();
|
|
45
|
-
}
|
|
46
|
-
plot.hooks.bindEvents.push(function (plot, eventHolder) {
|
|
47
|
-
if (!plot.getOptions().crosshair.mode) return;
|
|
48
|
-
eventHolder.mouseout(onMouseOut);
|
|
49
|
-
eventHolder.mousemove(onMouseMove);
|
|
50
|
-
});
|
|
51
|
-
plot.hooks.drawOverlay.push(function (plot, ctx) {
|
|
52
|
-
var c = plot.getOptions().crosshair;
|
|
53
|
-
if (!c.mode) return;
|
|
54
|
-
var plotOffset = plot.getPlotOffset();
|
|
55
|
-
ctx.save();
|
|
56
|
-
ctx.translate(plotOffset.left, plotOffset.top);
|
|
57
|
-
if (crosshair.x != -1) {
|
|
58
|
-
var adj = plot.getOptions().crosshair.lineWidth % 2 ? 0.5 : 0;
|
|
59
|
-
ctx.strokeStyle = c.color;
|
|
60
|
-
ctx.lineWidth = c.lineWidth;
|
|
61
|
-
ctx.lineJoin = "round";
|
|
62
|
-
ctx.beginPath();
|
|
63
|
-
if (c.mode.indexOf("x") != -1) {
|
|
64
|
-
var drawX = Math.floor(crosshair.x) + adj;
|
|
65
|
-
ctx.moveTo(drawX, 0);
|
|
66
|
-
ctx.lineTo(drawX, plot.height());
|
|
67
|
-
}
|
|
68
|
-
if (c.mode.indexOf("y") != -1) {
|
|
69
|
-
var drawY = Math.floor(crosshair.y) + adj;
|
|
70
|
-
ctx.moveTo(0, drawY);
|
|
71
|
-
ctx.lineTo(plot.width(), drawY);
|
|
72
|
-
}
|
|
73
|
-
ctx.stroke();
|
|
74
|
-
}
|
|
75
|
-
ctx.restore();
|
|
76
|
-
});
|
|
77
|
-
plot.hooks.shutdown.push(function (plot, eventHolder) {
|
|
78
|
-
eventHolder.unbind("mouseout", onMouseOut);
|
|
79
|
-
eventHolder.unbind("mousemove", onMouseMove);
|
|
80
|
-
});
|
|
81
|
-
}
|
|
82
|
-
$.plot.plugins.push({ init: init, options: options, name: "crosshair", version: "1.0" });
|
|
83
|
-
})(jQuery);
|
|
1
|
+
/* Javascript plotting library for jQuery, version 0.8.3.
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2007-2014 IOLA and Ole Laursen.
|
|
4
|
+
Licensed under the MIT license.
|
|
5
|
+
|
|
6
|
+
*/
|
|
7
|
+
(function ($) {
|
|
8
|
+
var options = { crosshair: { mode: null, color: "rgba(170, 0, 0, 0.80)", lineWidth: 1 } };
|
|
9
|
+
function init(plot) {
|
|
10
|
+
var crosshair = { x: -1, y: -1, locked: false };
|
|
11
|
+
plot.setCrosshair = function setCrosshair(pos) {
|
|
12
|
+
if (!pos) crosshair.x = -1;
|
|
13
|
+
else {
|
|
14
|
+
var o = plot.p2c(pos);
|
|
15
|
+
crosshair.x = Math.max(0, Math.min(o.left, plot.width()));
|
|
16
|
+
crosshair.y = Math.max(0, Math.min(o.top, plot.height()));
|
|
17
|
+
}
|
|
18
|
+
plot.triggerRedrawOverlay();
|
|
19
|
+
};
|
|
20
|
+
plot.clearCrosshair = plot.setCrosshair;
|
|
21
|
+
plot.lockCrosshair = function lockCrosshair(pos) {
|
|
22
|
+
if (pos) plot.setCrosshair(pos);
|
|
23
|
+
crosshair.locked = true;
|
|
24
|
+
};
|
|
25
|
+
plot.unlockCrosshair = function unlockCrosshair() {
|
|
26
|
+
crosshair.locked = false;
|
|
27
|
+
};
|
|
28
|
+
function onMouseOut(e) {
|
|
29
|
+
if (crosshair.locked) return;
|
|
30
|
+
if (crosshair.x != -1) {
|
|
31
|
+
crosshair.x = -1;
|
|
32
|
+
plot.triggerRedrawOverlay();
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
function onMouseMove(e) {
|
|
36
|
+
if (crosshair.locked) return;
|
|
37
|
+
if (plot.getSelection && plot.getSelection()) {
|
|
38
|
+
crosshair.x = -1;
|
|
39
|
+
return;
|
|
40
|
+
}
|
|
41
|
+
var offset = plot.offset();
|
|
42
|
+
crosshair.x = Math.max(0, Math.min(e.pageX - offset.left, plot.width()));
|
|
43
|
+
crosshair.y = Math.max(0, Math.min(e.pageY - offset.top, plot.height()));
|
|
44
|
+
plot.triggerRedrawOverlay();
|
|
45
|
+
}
|
|
46
|
+
plot.hooks.bindEvents.push(function (plot, eventHolder) {
|
|
47
|
+
if (!plot.getOptions().crosshair.mode) return;
|
|
48
|
+
eventHolder.mouseout(onMouseOut);
|
|
49
|
+
eventHolder.mousemove(onMouseMove);
|
|
50
|
+
});
|
|
51
|
+
plot.hooks.drawOverlay.push(function (plot, ctx) {
|
|
52
|
+
var c = plot.getOptions().crosshair;
|
|
53
|
+
if (!c.mode) return;
|
|
54
|
+
var plotOffset = plot.getPlotOffset();
|
|
55
|
+
ctx.save();
|
|
56
|
+
ctx.translate(plotOffset.left, plotOffset.top);
|
|
57
|
+
if (crosshair.x != -1) {
|
|
58
|
+
var adj = plot.getOptions().crosshair.lineWidth % 2 ? 0.5 : 0;
|
|
59
|
+
ctx.strokeStyle = c.color;
|
|
60
|
+
ctx.lineWidth = c.lineWidth;
|
|
61
|
+
ctx.lineJoin = "round";
|
|
62
|
+
ctx.beginPath();
|
|
63
|
+
if (c.mode.indexOf("x") != -1) {
|
|
64
|
+
var drawX = Math.floor(crosshair.x) + adj;
|
|
65
|
+
ctx.moveTo(drawX, 0);
|
|
66
|
+
ctx.lineTo(drawX, plot.height());
|
|
67
|
+
}
|
|
68
|
+
if (c.mode.indexOf("y") != -1) {
|
|
69
|
+
var drawY = Math.floor(crosshair.y) + adj;
|
|
70
|
+
ctx.moveTo(0, drawY);
|
|
71
|
+
ctx.lineTo(plot.width(), drawY);
|
|
72
|
+
}
|
|
73
|
+
ctx.stroke();
|
|
74
|
+
}
|
|
75
|
+
ctx.restore();
|
|
76
|
+
});
|
|
77
|
+
plot.hooks.shutdown.push(function (plot, eventHolder) {
|
|
78
|
+
eventHolder.unbind("mouseout", onMouseOut);
|
|
79
|
+
eventHolder.unbind("mousemove", onMouseMove);
|
|
80
|
+
});
|
|
81
|
+
}
|
|
82
|
+
$.plot.plugins.push({ init: init, options: options, name: "crosshair", version: "1.0" });
|
|
83
|
+
})(jQuery);
|