Skip to content

texttemplate with date formatting #4071

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 43 commits into from
Aug 28, 2019
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
43 commits
Select commit Hold shift + click to select a range
8deaed1
texttemplate: initial implementation
antoinerg Jul 22, 2019
ce3c9cc
move texttemplate_attributes.js from fx to plots
antoinerg Jul 23, 2019
ee0a309
do not export `templateFormatString`
antoinerg Jul 23, 2019
9330290
texttemplate: test that textinfo is not coerced when it's defined
antoinerg Jul 23, 2019
cf826dd
texttemplate: update description
antoinerg Jul 23, 2019
c3e9961
set texttemplate dflt back to ''
antoinerg Jul 23, 2019
e0bde45
texttemplate: add customdata variable and :lock: down with test
antoinerg Jul 23, 2019
902d2d3
texttemplate: add support for scatter(carpet|geo|polar|ternary)
antoinerg Jul 24, 2019
0b516f7
texttemplate: use result of appendArrayPointValue as available variables
antoinerg Jul 24, 2019
7d21680
texttemplate: fix scattergeo variable names
antoinerg Jul 24, 2019
7fa4dc5
texttemplate: add support for scattergl
antoinerg Jul 24, 2019
aeb6d1f
texttemplate: add support for scatterpolargl
antoinerg Aug 6, 2019
f9062e4
texttemplate: add support for scatter3d
antoinerg Aug 6, 2019
3ad30ab
Merge branch 'master' into texttemplate
antoinerg Aug 6, 2019
2d50269
Merge branch 'texttemplate-gl' into texttemplate
antoinerg Aug 6, 2019
05f4722
check_texttemplate: put @gl tests in its own `it` block
antoinerg Aug 6, 2019
6729286
split gl2d and gl3d in separate mocks
antoinerg Aug 6, 2019
cbbcfcb
texttemplate: use d3locale in GL traces, fix style
antoinerg Aug 7, 2019
11ea019
Merge branch 'texttemplate-split' into texttemplate
antoinerg Aug 7, 2019
32498f8
remove unused baseline `texttemplate_2`
antoinerg Aug 7, 2019
7bb3379
texttemplate: text in legends should not changed
antoinerg Aug 13, 2019
9677929
texttemplate: fix GL traces with txt array longer than data
antoinerg Aug 13, 2019
b9188a9
Merge branch 'master' into texttemplate
antoinerg Aug 13, 2019
decec45
scattergl: :lock: down handling of texttemplate with fewer elements t…
antoinerg Aug 13, 2019
2f6bf8a
scattergl: make sure text(template) is not mutated
antoinerg Aug 13, 2019
e7c034a
texttemplate: test that trace.meta is passed to template
antoinerg Aug 14, 2019
4b1face
texttemplate: pass trace._meta to gl2d traces
antoinerg Aug 14, 2019
2528aa6
Merge branch 'master' into texttemplate
antoinerg Aug 14, 2019
e381c25
Merge branch 'texttemplate-meta' into texttemplate
antoinerg Aug 14, 2019
888cf68
texttemplate: DRY code for gl(2|3)d traces, pass meta to scatter3d
antoinerg Aug 14, 2019
7d3fabb
texttemplate: add support for scattermapbox
antoinerg Aug 7, 2019
b2df623
funnelarea: fix description of variables in (hover|text)template
antoinerg Aug 20, 2019
8c339df
funnel(area): fix description of variables for (hover|text)template
antoinerg Aug 21, 2019
c6370d9
support formatting date in (hover|text)template
antoinerg Aug 19, 2019
836d5a2
templateFormatString: use d3locale.timeFormat if available fot date fmt
antoinerg Aug 20, 2019
3dda912
texttemplate for scattermapbox: fix editType, improve style and mock
antoinerg Aug 26, 2019
354b70f
fix baseline "mapbox_texttemplate"
antoinerg Aug 27, 2019
4ef8392
merge (text|hover)templateAttrs() into a single file
antoinerg Aug 27, 2019
e700fc2
texttemplate: fix style
antoinerg Aug 27, 2019
6780a3d
texttemplate: do not coerce texttemplate when no text is displayed
antoinerg Aug 28, 2019
db87e62
(hover|text)template: pie/funnel/waterfall fix attribute definition
antoinerg Aug 28, 2019
daa2c7e
templateFormatString: do not error out when lookup objects are undefined
antoinerg Aug 28, 2019
c7dd845
don't coerce texttemplate when no text - fix for scatterternary
etpinard Aug 28, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/traces/bar/defaults.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ function supplyDefaults(traceIn, traceOut, defaultColor, layout) {
coerce('width');

coerce('text');
coerce('texttemplate');
coerce('hovertext');
coerce('hovertemplate');

Expand Down Expand Up @@ -156,6 +155,8 @@ function handleText(traceIn, traceOut, layout, coerce, textposition, opts) {
if(moduleHasConstrain) coerce('constraintext');
if(moduleHasCliponaxis) coerce('cliponaxis');
if(moduleHasTextangle) coerce('textangle');

coerce('texttemplate');
}

if(hasInside) {
Expand Down
1 change: 0 additions & 1 deletion src/traces/funnel/defaults.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ function supplyDefaults(traceIn, traceOut, defaultColor, layout) {
coerce('width');

var text = coerce('text');
coerce('texttemplate');

coerce('hovertext');
coerce('hovertemplate');
Expand Down
2 changes: 1 addition & 1 deletion src/traces/scatter/defaults.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ module.exports = function supplyDefaults(traceIn, traceOut, defaultColor, layout
var defaultMode = !stackGroupOpts && (len < constants.PTS_LINESONLY) ?
'lines+markers' : 'lines';
coerce('text');
coerce('texttemplate');
coerce('hovertext');
coerce('mode', defaultMode);

Expand All @@ -53,6 +52,7 @@ module.exports = function supplyDefaults(traceIn, traceOut, defaultColor, layout
}

if(subTypes.hasText(traceOut)) {
coerce('texttemplate');
handleTextDefaults(traceIn, traceOut, layout, coerce);
}

Expand Down
2 changes: 1 addition & 1 deletion src/traces/scatter3d/defaults.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ module.exports = function supplyDefaults(traceIn, traceOut, defaultColor, layout
}

coerce('text');
coerce('texttemplate');
coerce('hovertext');
coerce('hovertemplate');
coerce('mode');
Expand All @@ -46,6 +45,7 @@ module.exports = function supplyDefaults(traceIn, traceOut, defaultColor, layout
}

if(subTypes.hasText(traceOut)) {
coerce('texttemplate');
handleTextDefaults(traceIn, traceOut, layout, coerce, {noSelect: true});
}

Expand Down
2 changes: 1 addition & 1 deletion src/traces/scatter3d/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ module.exports = {
moduleType: 'trace',
name: 'scatter3d',
basePlotModule: require('../../plots/gl3d'),
categories: ['gl3d', 'symbols', 'showLegend'],
categories: ['gl3d', 'symbols', 'showLegend', 'scatter-like'],
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why did you add 'scatter-like' here?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see, you're using traceIs(trace, 'scatter-like') in your tests. A quick grep reveals that 'scatter-like' is only used in two places, in modebar/manage.js and for some restyle call. Adding it to scatter3d won't break anything and is arguably the thing to do, so I'm 👌 with this.

meta: {
hrName: 'scatter_3d',
description: [
Expand Down
2 changes: 1 addition & 1 deletion src/traces/scattergeo/defaults.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ module.exports = function supplyDefaults(traceIn, traceOut, defaultColor, layout
}

coerce('text');
coerce('texttemplate');
coerce('hovertext');
coerce('hovertemplate');
coerce('mode');
Expand All @@ -47,6 +46,7 @@ module.exports = function supplyDefaults(traceIn, traceOut, defaultColor, layout
}

if(subTypes.hasText(traceOut)) {
coerce('texttemplate');
handleTextDefaults(traceIn, traceOut, layout, coerce);
}

Expand Down
2 changes: 1 addition & 1 deletion src/traces/scattergl/defaults.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ module.exports = function supplyDefaults(traceIn, traceOut, defaultColor, layout
var defaultMode = len < constants.PTS_LINESONLY ? 'lines+markers' : 'lines';

coerce('text');
coerce('texttemplate');
coerce('hovertext');
coerce('hovertemplate');
coerce('mode', defaultMode);
Expand All @@ -53,6 +52,7 @@ module.exports = function supplyDefaults(traceIn, traceOut, defaultColor, layout
}

if(subTypes.hasText(traceOut)) {
coerce('texttemplate');
handleTextDefaults(traceIn, traceOut, layout, coerce);
}

Expand Down
2 changes: 1 addition & 1 deletion src/traces/scattermapbox/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ module.exports = {
moduleType: 'trace',
name: 'scattermapbox',
basePlotModule: require('../../plots/mapbox'),
categories: ['mapbox', 'gl', 'symbols', 'showLegend', 'scatterlike'],
categories: ['mapbox', 'gl', 'symbols', 'showLegend', 'scatter-like'],
meta: {
hrName: 'scatter_mapbox',
description: [
Expand Down
2 changes: 1 addition & 1 deletion src/traces/scatterpolar/defaults.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ function supplyDefaults(traceIn, traceOut, defaultColor, layout) {
coerce('thetaunit');
coerce('mode', len < PTS_LINESONLY ? 'lines+markers' : 'lines');
coerce('text');
coerce('texttemplate');
coerce('hovertext');
if(traceOut.hoveron !== 'fills') coerce('hovertemplate');

Expand All @@ -49,6 +48,7 @@ function supplyDefaults(traceIn, traceOut, defaultColor, layout) {
}

if(subTypes.hasText(traceOut)) {
coerce('texttemplate');
handleTextDefaults(traceIn, traceOut, layout, coerce);
}

Expand Down
2 changes: 1 addition & 1 deletion src/traces/scatterpolargl/defaults.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ module.exports = function supplyDefaults(traceIn, traceOut, defaultColor, layout
coerce('thetaunit');
coerce('mode', len < PTS_LINESONLY ? 'lines+markers' : 'lines');
coerce('text');
coerce('texttemplate');
coerce('hovertext');
if(traceOut.hoveron !== 'fills') coerce('hovertemplate');

Expand All @@ -48,6 +47,7 @@ module.exports = function supplyDefaults(traceIn, traceOut, defaultColor, layout
}

if(subTypes.hasText(traceOut)) {
coerce('texttemplate');
handleTextDefaults(traceIn, traceOut, layout, coerce);
}

Expand Down
33 changes: 28 additions & 5 deletions test/jasmine/assets/check_texttemplate.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,39 @@ var supplyAllDefaults = require('../assets/supply_defaults');
module.exports = function checkTextTemplate(mock, selector, tests) {
var isGL = Registry.traceIs(mock[0].type, 'gl');
var isPolar = Registry.traceIs(mock[0].type, 'polar');
var isScatterLike = Registry.traceIs(mock[0].type, 'scatter-like');
var isBarLike = Registry.traceIs(mock[0].type, 'bar-like');

it('should not coerce textinfo when texttemplate', function() {
it('should not coerce textinfo when texttemplate is defined', function() {
var gd = {};
gd.data = Lib.extendDeep(mock, {});
gd.data = Lib.extendDeep([], mock);
gd.data[0].textinfo = 'text';
gd.data[0].texttemplate = tests[0][0];
gd.data[0].texttemplate = 'texttemplate';
supplyAllDefaults(gd);
expect(gd._fullData[0].textinfo).toBe(undefined);
});

if(isScatterLike) {
it('should not coerce texttemplate when mode has no `text` flag', function() {
var gd = {};
gd.data = Lib.extendDeep([], mock);
gd.data[0].mode = 'markers';
gd.data[0].texttemplate = 'texttemplate';
supplyAllDefaults(gd);
expect(gd._fullData[0].texttemplate).toBe(undefined);
});
}

if(isBarLike) {
it('should not coerce texttemplate when textposition is `none`', function() {
var gd = {};
gd.data = Lib.extendDeep([], mock);
gd.data[0].textposition = 'none';
gd.data[0].texttemplate = 'texttemplate';
supplyAllDefaults(gd);
expect(gd._fullData[0].texttemplate).toBe(undefined);
});
}

var N = tests[0][1].length;
var i;
Expand All @@ -46,7 +69,7 @@ module.exports = function checkTextTemplate(mock, selector, tests) {
tests.forEach(function(test) {
it('@gl should support texttemplate', function(done) {
var gd = createGraphDiv();
var mockCopy = Lib.extendDeep(mock, {});
var mockCopy = Lib.extendDeep([], mock);
mockCopy[0].texttemplate = test[0];
Plotly.newPlot(gd, mockCopy)
.then(function() {
Expand Down Expand Up @@ -78,7 +101,7 @@ module.exports = function checkTextTemplate(mock, selector, tests) {
tests.forEach(function(test) {
it('should support texttemplate', function(done) {
var gd = createGraphDiv();
var mockCopy = Lib.extendDeep(mock, {});
var mockCopy = Lib.extendDeep([], mock);
mockCopy[0].texttemplate = test[0];
Plotly.newPlot(gd, mockCopy)
.then(function() {
Expand Down