This repository was archived by the owner on Jul 30, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathtooltip.js
More file actions
131 lines (131 loc) · 8.26 KB
/
tooltip.js
File metadata and controls
131 lines (131 loc) · 8.26 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
"use strict";
var __extends = (this && this.__extends) || (function () {
var extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
return function (d, b) {
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
Object.defineProperty(exports, "__esModule", { value: true });
var React = require("react");
var ej2_react_lineargauge_1 = require("@syncfusion/ej2-react-lineargauge");
var sample_base_1 = require("../common/sample-base");
var SAMPLE_CSS = "\n .control-fluid {\n\t\tpadding: 0px !important;\n }";
/**
* Linear gauge tooltip sample
*/
var Tooltip = (function (_super) {
__extends(Tooltip, _super);
function Tooltip() {
return _super !== null && _super.apply(this, arguments) || this;
}
Tooltip.prototype.load = function (args) {
var selectedTheme = location.hash.split('/')[1];
selectedTheme = selectedTheme ? selectedTheme : 'Material';
args.gauge.theme = (selectedTheme.charAt(0).toUpperCase() + selectedTheme.slice(1));
};
Tooltip.prototype.render = function () {
var _this = this;
return (React.createElement("div", { className: 'control-pane' },
React.createElement("style", null, SAMPLE_CSS),
React.createElement("div", { className: 'control-section' },
React.createElement(ej2_react_lineargauge_1.LinearGaugeComponent, { id: 'tooltipContainer', ref: function (gauge) { return _this.gaugeInstance = gauge; }, orientation: 'Horizontal', axisLabelRender: this.labelRender.bind(this), load: this.gaugeLoad.bind(this), loaded: this.gaugeLoaded.bind(this), resized: this.gaugeResized.bind(this), tooltipRender: this.tooltipRender.bind(this), container: { width: 140, border: { width: 2, color: '#a6a6a6' } }, tooltip: { enable: true, fill: '#fffff', textStyle: { color: '#fffff' } } },
React.createElement(ej2_react_lineargauge_1.Inject, { services: [ej2_react_lineargauge_1.Annotations, ej2_react_lineargauge_1.GaugeTooltip] }),
React.createElement(ej2_react_lineargauge_1.AxesDirective, null,
React.createElement(ej2_react_lineargauge_1.AxisDirective, { minimum: 0, maximum: 10, majorTicks: { interval: 1 }, minorTicks: { interval: 0.2 }, line: { offset: 140 }, labelStyle: { font: { color: '#000000' } } },
React.createElement(ej2_react_lineargauge_1.PointersDirective, null,
React.createElement(ej2_react_lineargauge_1.PointerDirective, { type: 'Bar', value: 5.4, color: '#ff66b3', offset: 15 }))),
React.createElement(ej2_react_lineargauge_1.AxisDirective, { opposedPosition: true, minimum: 0, maximum: 25, majorTicks: { interval: 1 }, minorTicks: { interval: 0.2 }, line: { offset: -140 }, labelStyle: { font: { color: '#000000' } } },
React.createElement(ej2_react_lineargauge_1.PointersDirective, null,
React.createElement(ej2_react_lineargauge_1.PointerDirective, { type: 'Bar', value: 16.5, color: '#4d94ff', offset: -15 })))),
React.createElement(ej2_react_lineargauge_1.AnnotationsDirective, null,
React.createElement(ej2_react_lineargauge_1.AnnotationDirective, { content: '<div id="first"><h1 style="font-size:15px">Inches</h1></div>', axisIndex: 0, axisValue: 5.4, x: 35, y: -58, zIndex: '1' }),
React.createElement(ej2_react_lineargauge_1.AnnotationDirective, { content: '<div id="second"><h1 style="font-size:15px">Centimeters</h1></div>', axisIndex: 1, axisValue: 16.5, x: 50, y: 52, zIndex: '1' })))),
React.createElement("div", { id: "action-description" },
React.createElement("p", null, "This sample visualizes the tooltip for pointer in gauge. To see tooltip in action, hover pointer or tap the pointer.")),
React.createElement("div", { id: "description" },
React.createElement("p", null,
"This sample demonstrates the default linear gauge. The linear gauge control indicates the values of scales in horizontal or vertical sliding meter. You can use ",
React.createElement("code", null, "axes"),
",",
React.createElement("code", null, "ranges"),
", ",
React.createElement("code", null, "pointers"),
" and ",
React.createElement("code", null, "container"),
" properties to customize the appearance of the gauge. In this sample, an axis with multiple ranges and a pointer has been used."),
React.createElement("p", null,
"More information about linear gauge can be found in this",
React.createElement("a", { target: "_blank", href: "http://ej2.syncfusion.com/documentation" }, "documentation section"),
"."))));
};
Tooltip.prototype.tooltipRender = function (args) {
args.content = (args.axis.visibleRange.max === 25) ? Number(args.content).toFixed(1) + ' cm' : Number(args.content).toFixed(1) + ' in';
};
Tooltip.prototype.gaugeLoad = function (args) {
var selectedTheme = location.hash.split('/')[1];
selectedTheme = selectedTheme ? selectedTheme : 'Material';
args.gauge.theme = (selectedTheme.charAt(0).toUpperCase() + selectedTheme.slice(1));
var width = Number(document.getElementById('tooltipContainer').offsetWidth);
if (width < 500) {
args.gauge.axes[1].majorTicks.interval = 2;
args.gauge.axes[1].minorTicks.interval = 1;
args.gauge.orientation = 'Vertical';
args.gauge.annotations[0].x = -57;
args.gauge.annotations[0].y = -30;
args.gauge.annotations[1].x = 50;
args.gauge.annotations[1].y = -45;
}
else {
args.gauge.axes[1].majorTicks.interval = 1;
args.gauge.axes[1].minorTicks.interval = 0.5;
args.gauge.orientation = 'Horizontal';
args.gauge.annotations[0].x = 35;
args.gauge.annotations[0].y = -58;
args.gauge.annotations[1].x = 50;
args.gauge.annotations[1].y = 52;
}
};
Tooltip.prototype.gaugeLoaded = function (args) {
if (document.getElementById('tooltipContainer')) {
if (args.gauge.availableSize.width < 500) {
document.getElementById('tooltipContainer_Annotation_0').style.transform = 'rotate(270deg)';
document.getElementById('tooltipContainer_Annotation_1').style.transform = 'rotate(270deg)';
}
else {
document.getElementById('tooltipContainer_Annotation_0').style.transform = '';
document.getElementById('tooltipContainer_Annotation_1').style.transform = '';
}
}
};
Tooltip.prototype.labelRender = function (args) {
if (args.axis.visibleRange.min === args.value || args.axis.visibleRange.max === args.value) {
args.text = '';
}
};
Tooltip.prototype.gaugeResized = function (args) {
if (args.currentSize.width < 500) {
this.gaugeInstance.axes[1].majorTicks.interval = 2;
this.gaugeInstance.axes[1].minorTicks.interval = 1;
this.gaugeInstance.orientation = 'Vertical';
this.gaugeInstance.annotations[0].x = -57;
this.gaugeInstance.annotations[0].y = -30;
this.gaugeInstance.annotations[1].x = 50;
this.gaugeInstance.annotations[1].y = -45;
}
else {
this.gaugeInstance.axes[1].majorTicks.interval = 1;
this.gaugeInstance.axes[1].minorTicks.interval = 0.5;
this.gaugeInstance.orientation = 'Horizontal';
this.gaugeInstance.annotations[0].x = 35;
this.gaugeInstance.annotations[0].y = -58;
this.gaugeInstance.annotations[1].x = 50;
this.gaugeInstance.annotations[1].y = 52;
}
};
return Tooltip;
}(sample_base_1.SampleBase));
exports.Tooltip = Tooltip;