8000 Added schema and cleanup · kb-/plotly.js@a617412 · GitHub
[go: up one dir, main page]

Skip to content

Commit a617412

Browse files
committed
Added schema and cleanup
1 parent dcb5eec commit a617412

File tree

10 files changed

+123
-277
lines changed

10 files changed

+123
-277
lines changed

demo/index.html

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
<meta charset="UTF-8">
55
<title>Plotly Tooltip Button Test</title>
66
<script src="../dist/plotly.js"></script>
7+
<script src="../dist/plotly-locale-de.js"></script>
78
<style>
89
body {
910
font-family: Arial, sans-serif;
@@ -61,7 +62,15 @@ <h1>Plotly Tooltip Button Test</h1>
6162
}
6263
};
6364

64-
var data = [trace1];
65+
var trace2 = {
66+
name: 'Trace 2',
67+
x: generateDateTime('2024-04-01T12:00:00Z', 5),
68+
y: generateRandomYValues(5),
69+
type: 'scatter',
70+
tooltiptemplate: "%{fullData.name}<br>%{x|%H:%M:%S}<br>y: %{y:.2e}",
71+
};
72+
73+
var data = [trace1, trace2];
6574

6675
var layout = {
6776
title: 'Custom Tooltip Example'
@@ -71,7 +80,8 @@ <h1>Plotly Tooltip Button Test</h1>
7180
editable: true,//editable is important to allow Tooltip drag-positionning and deletion
7281
modeBarButtonsToAdd: ['tooltip', 'hoverclosest', 'hovercompare', 'togglespikelines'], // Add the tooltip button
7382
displaylogo: false, // Optionally hide the Plotly logo
74-
displayModeBar: true // Ensure the modebar is displayed
83+
displayModeBar: true, // Ensure the modebar is displayed
84+
locale: 'de'
7585
};
7686

7787
Plotly.newPlot('plot', data, layout, config).then(function() {

dist/plotly-strict.js

Lines changed: 22 additions & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -14361,69 +14361,6 @@ modeBarButtons.toggleSpikelines = {
1436114361
Registry.call('_guiRelayout', gd, setSpikelineVisibility(gd));
1436214362
}
1436314363
};
14364-
14365-
// modeBarButtons.tooltip = {
14366-
// name: 'tooltip',
14367-
// title: function(gd) { return _(gd, 'Add Tooltip to Points'); },
14368-
// icon: Icons.tooltip_annotate,
14369-
// attr: '_tooltipEnabled',
14370-
// val: 'on',
14371-
// click: function(gd) {
14372-
// var fullLayout = gd._fullLayout;
14373-
// var tooltipEnabled = fullLayout._tooltipEnabled;
14374-
14375-
// fullLayout._tooltipEnabled = tooltipEnabled === 'on' ? 'off' : 'on';
14376-
14377-
// if (fullLayout._tooltipEnabled === 'on') {
14378-
// gd.on('plotly_click', function(data) { addTooltip(gd, data); });
14379-
// } else {
14380-
// gd.removeListener('plotly_click', function(data) { addTooltip(gd, data); });
14381-
// }
14382-
14383-
//Print to console for testing
14384-
// console.log('Tooltip is now', fullLayout._tooltipEnabled);
14385-
// }
14386-
// };
14387-
14388-
// function addTooltip(gd, data) {
14389-
// var pts = data.points[0];
14390-
// var fullLayout = gd._fullLayout;
14391-
14392-
// var newAnnotation = {
14393-
// x: pts.x,
14394-
// y: pts.y,
14395-
// xref: 'x',
14396-
// yref: 'y',
14397-
// text: `x: ${pts.x},<br>y: ${pts.y}`,
14398-
// showarrow: true,
14399-
// arrowhead: 7,
14400-
// ax: 0,
14401-
// ay: -40,
14402-
// font: {
14403-
// color: 'black',
14404-
// family: 'Arial',
14405-
// size: 12
14406-
// },
14407-
// arrowcolor: 'black',
14408-
// arrowsize: 1.8,
14409-
// arrowwidth: 1,
14410-
// xanchor: 'left',
14411-
// align: 'left'
14412-
// };
14413-
14414-
// var existingIndex = fullLayout.annotations.findIndex(function(ann) {
14415-
// return ann.x === pts.x && ann.y === pts.y;
14416-
// });
14417-
14418-
// if (existingIndex === -1) {
14419-
// fullLayout.annotations.push(newAnnotation);
14420-
// Plotly.relayout(gd, { annotations: fullLayout.annotations });
14421-
// }
14422-
// }
14423-
14424-
/**
14425-
* ModeBar buttons configuration
14426-
*/
1442714364
modeBarButtons.tooltip = {
1442814365
name: 'tooltip',
1442914366
title: function (gd) {
@@ -14448,15 +14385,12 @@ modeBarButtons.tooltip = {
1444814385
} else {
1444914386
gd.removeListener('plotly_click', gd._tooltipClickHandler);
1445014387
}
14451-
if (mustRun) {
14452-
mustRun = false;
14388+
if (!gd._relayoutHandlerAdded) {
14389+
gd._relayoutHandlerAdded = true;
1445314390
gd.on('plotly_relayout', function (eventData) {
1445414391
removeEmptyAnnotations(gd, eventData);
1445514392
});
1445614393
}
14457-
14458-
// Print to console for testing
14459-
console.log('Tooltip is now', fullLayout._tooltipEnabled);
1446014394
}
1446114395
};
1446214396
function tooltipClickHandler(gd, data, userTemplate, customStyle) {
@@ -62810,6 +62744,20 @@ exports.rb = function (opts, extra) {
6281062744
}
6281162745
return hovertemplate;
6281262746
};
62747+
exports.AG = function (opts, extra) {
62748+
opts = opts || {};
62749+
extra = extra || {};
62750+
var descPart = describeVariables(extra);
62751+
var tooltiptemplate = {
62752+
valType: 'string',
62753+
dflt: '',
62754+
editType: opts.editType || 'none'
62755+
};
62756+
if (opts.arrayOk !== false) {
62757+
tooltiptemplate.arrayOk = true;
62758+
}
62759+
return tooltiptemplate;
62760+
};
6281362761
exports.ay = function (opts, extra) {
6281462762
opts = opts || {};
6281562763
extra = extra || {};
@@ -96654,6 +96602,8 @@ module.exports = function arraysToCalcdata(cd, trace) {
9665496602
var axisHoverFormat = (__webpack_require__(17108).axisHoverFormat);
9665596603
var texttemplateAttrs = (__webpack_require__(12724)/* .texttemplateAttrs */ .ay);
9665696604
var hovertemplateAttrs = (__webpack_require__(12724)/* .hovertemplateAttrs */ .rb);
96605+
var tooltiptemplateAttrs = (__webpack_require__(12724)/* .tooltiptemplateAttrs */ .AG);
96606+
var annotationAttrs = __webpack_require__(82850);
9665796607
var colorScaleAttrs = __webpack_require__(7415);
9665896608
var fontAttrs = __webpack_require__(13901);
9665996609
var dash = (__webpack_require__(35918)/* .dash */ .T);
@@ -97036,6 +96986,10 @@ module.exports = {
9703696986
colorEditType: 'style',
9703796987
arrayOk: true
9703896988
}),
96989+
tooltip: annotationAttrs,
96990+
tooltiptemplate: tooltiptemplateAttrs({}, {
96991+
keys: constants.eventDataKeys
96992+
}),
9703996993
zorder: {
9704096994
valType: 'integer',
9704196995
dflt: 0,

dist/plotly-strict.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/plotly-with-meta.js

Lines changed: 25 additions & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -14589,69 +14589,6 @@ modeBarButtons.toggleSpikelines = {
1458914589
Registry.call('_guiRelayout', gd, setSpikelineVisibility(gd));
1459014590
}
1459114591
};
14592-
14593-
// modeBarButtons.tooltip = {
14594-
// name: 'tooltip',
14595-
// title: function(gd) { return _(gd, 'Add Tooltip to Points'); },
14596-
// icon: Icons.tooltip_annotate,
14597-
// attr: '_tooltipEnabled',
14598-
// val: 'on',
14599-
// click: function(gd) {
14600-
// var fullLayout = gd._fullLayout;
14601-
// var tooltipEnabled = fullLayout._tooltipEnabled;
14602-
14603-
// fullLayout._tooltipEnabled = tooltipEnabled === 'on' ? 'off' : 'on';
14604-
14605-
// if (fullLayout._tooltipEnabled === 'on') {
14606-
// gd.on('plotly_click', function(data) { addTooltip(gd, data); });
14607-
// } else {
14608-
// gd.removeListener('plotly_click', function(data) { addTooltip(gd, data); });
14609-
// }
14610-
14611-
//Print to console for testing
14612-
// console.log('Tooltip is now', fullLayout._tooltipEnabled);
14613-
// }
14614-
// };
14615-
14616-
// function addTooltip(gd, data) {
14617-
// var pts = data.points[0];
14618-
// var fullLayout = gd._fullLayout;
14619-
14620-
// var newAnnotation = {
14621-
// x: pts.x,
14622-
// y: pts.y,
14623-
// xref: 'x',
14624-
// yref: 'y',
14625-
// text: `x: ${pts.x},<br>y: ${pts.y}`,
14626-
// showarrow: true,
14627-
// arrowhead: 7,
14628-
// ax: 0,
14629-
// ay: -40,
14630-
// font: {
14631-
// color: 'black',
14632-
// family: 'Arial',
14633-
// size: 12
14634-
// },
14635-
// arrowcolor: 'black',
14636-
// arrowsize: 1.8,
14637-
// arrowwidth: 1,
14638-
// xanchor: 'left',
14639-
// align: 'left'
14640-
// };
14641-
14642-
// var existingIndex = fullLayout.annotations.findIndex(function(ann) {
14643-
// return ann.x === pts.x && ann.y === pts.y;
14644-
// });
14645-
14646-
// if (existingIndex === -1) {
14647-
// fullLayout.annotations.push(newAnnotation);
14648-
// Plotly.relayout(gd, { annotations: fullLayout.annotations });
14649-
// }
14650-
// }
14651-
14652-
/**
14653-
* ModeBar buttons configuration
14654-
*/
1465514592
modeBarButtons.tooltip = {
1465614593
name: 'tooltip',
1465714594
title: function (gd) {
@@ -14676,15 +14613,12 @@ modeBarButtons.tooltip = {
1467614613
} else {
1467714614
gd.removeListener('plotly_click', gd._tooltipClickHandler);
1467814615
}
14679-
if (mustRun) {
14680-
mustRun = false;
14616+
if (!gd._relayoutHandlerAdded) {
14617+
gd._relayoutHandlerAdded = true;
1468114618
gd.on('plotly_relayout', function (eventData) {
1468214619
removeEmptyAnnotations(gd, eventData);
1468314620
});
1468414621
}
14685-
14686-
// Print to console for testing
14687-
console.log('Tooltip is now', fullLayout._tooltipEnabled);
1468814622
}
1468914623
};
1469014624
function tooltipClickHandler(gd, data, userTemplate, customStyle) {
@@ -63631,6 +63565,23 @@ exports.rb = function (opts, extra) {
6363163565
}
6363263566
return hovertemplate;
6363363567
};
63568+
exports.AG = function (opts, extra) {
63569+
opts = opts || {};
63570+
extra = extra || {};
63571+
var descPart = describeVariables(extra);
63572+
var tooltiptemplate = {
63573+
valType: 'string',
63574+
dflt: '',
63575+
editType: opts.editType || 'none',
63576+
description: ['Template string used for rendering the information that appear on tooltip box.', 'The parameters and syntax are the same than for hovertemplate.', 'Note that this will override `tooltipinfo`.', templateFormatStringDescription({
63577+
supportOther: true
63578+
}), 'The variables available in `tooltiptemplate` are the ones emitted as event data described at this link https://plotly.com/javascript/plotlyjs-events/#event-data.', 'Additionally, every attributes that can be specified per-point (the ones that are `arrayOk: true`) are available.', descPart].join(' ')
63579+
};
63580+
if (opts.arrayOk !== false) {
63581+
tooltiptemplate.arrayOk = true;
63582+
}
63583+
return tooltiptemplate;
63584+
};
6363463585
exports.ay = function (opts, extra) {
6363563586
opts = opts || {};
6363663587
extra = extra || {};
@@ -98033,6 +97984,8 @@ module.exports = function arraysToCalcdata(cd, trace) {
9803397984
var axisHoverFormat = (__webpack_require__(88007).axisHoverFormat);
9803497985
var texttemplateAttrs = (__webpack_require__(97661)/* .texttemplateAttrs */ .ay);
9803597986
var hovertemplateAttrs = (__webpack_require__(97661)/* .hovertemplateAttrs */ .rb);
97987+
var tooltiptemplateAttrs = (__webpack_require__(97661)/* .tooltiptemplateAttrs */ .AG);
97988+
var annotationAttrs = __webpack_require__(40191);
9803697989
var colorScaleAttrs = __webpack_require__(3760);
9803797990
var fontAttrs = __webpack_require__(58432);
9803897991
var dash = (__webpack_require__(40787)/* .dash */ .T);
@@ -98475,6 +98428,10 @@ module.exports = {
9847598428
arrayOk: true,
9847698429
description: 'Sets the text font.'
9847798430
}),
98431+
tooltip: annotationAttrs,
98432+
tooltiptemplate: tooltiptemplateAttrs({}, {
98433+
keys: constants.eventDataKeys
98434+
}),
9847898435
zorder: {
9847998436
valType: 'integer',
9848098437
dflt: 0,

0 commit comments

Comments
 (0)
0