Skip to content

Commit

Permalink
Merge pull request #4044 from plotly/tickformat-docs-link
Browse files Browse the repository at this point in the history
Fix tickformat attribute description links
  • Loading branch information
etpinard authored Jul 12, 2019
2 parents 14133af + 2ec994f commit 674f0b0
Show file tree
Hide file tree
Showing 9 changed files with 45 additions and 15 deletions.
5 changes: 4 additions & 1 deletion src/components/fx/hovertemplate_attributes.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@

'use strict';

var FORMAT_LINK = require('../../constants/docs').FORMAT_LINK;

module.exports = function(opts, extra) {
opts = opts || {};
extra = extra || {};
Expand Down Expand Up @@ -37,7 +39,8 @@ module.exports = function(opts, extra) {
'Note that this will override `hoverinfo`.',
'Variables are inserted using %{variable}, for example "y: %{y}".',
'Numbers are formatted using d3-format\'s syntax %{variable:d3-format}, for example "Price: %{y:$.2f}".',
'See https://github.com/d3/d3-format/blob/master/README.md#locale_format for details on the formatting syntax.',
FORMAT_LINK,
'for details on the formatting syntax.',
'The variables available in `hovertemplate` are the ones emitted as event data described at this link https://plot.ly/javascript/plotlyjs-events/#event-data.',
'Additionally, every attributes that can be specified per-point (the ones that are `arrayOk: true`) are available.',
descPart,
Expand Down
14 changes: 14 additions & 0 deletions src/constants/docs.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
/**
* Copyright 2012-2019, Plotly, Inc.
* All rights reserved.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/

'use strict';

module.exports = {
FORMAT_LINK: 'https://github.com/d3/d3-3.x-api-reference/blob/master/Formatting.md#d3_format',
DATE_FORMAT_LINK: 'https://github.com/d3/d3-3.x-api-reference/blob/master/Time-Formatting.md#format'
};
12 changes: 7 additions & 5 deletions src/plots/cartesian/layout_attributes.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,10 @@ var dash = require('../../components/drawing/attributes').dash;
var extendFlat = require('../../lib/extend').extendFlat;
var templatedArray = require('../../plot_api/plot_template').templatedArray;

var constants = require('./constants');
var FORMAT_LINK = require('../../constants/docs').FORMAT_LINK;
var DATE_FORMAT_LINK = require('../../constants/docs').DATE_FORMAT_LINK;

var constants = require('./constants');

module.exports = {
visible: {
Expand Down Expand Up @@ -554,9 +556,9 @@ module.exports = {
description: [
'Sets the tick label formatting rule using d3 formatting mini-languages',
'which are very similar to those in Python. For numbers, see:',
'https://github.com/d3/d3-format/blob/master/README.md#locale_format',
FORMAT_LINK,
'And for dates see:',
'https://github.com/d3/d3-time-format/blob/master/README.md#locale_format',
DATE_FORMAT_LINK,
'We add one item to d3\'s date formatter: *%{n}f* for fractional seconds',
'with n digits. For example, *2016-10-13 09:15:23.456* with tickformat',
'*%H~%M~%S.%2f* would display *09~15~23.46*'
Expand Down Expand Up @@ -606,9 +608,9 @@ module.exports = {
description: [
'Sets the hover text formatting rule using d3 formatting mini-languages',
'which are very similar to those in Python. For numbers, see:',
'https://github.com/d3/d3-format/blob/master/README.md#locale_format',
FORMAT_LINK,
'And for dates see:',
'https://github.com/d3/d3-time-format/blob/master/README.md#locale_format',
DATE_FORMAT_LINK,
'We add one item to d3\'s date formatter: *%{n}f* for fractional seconds',
'with n digits. For example, *2016-10-13 09:15:23.456* with tickformat',
'*%H~%M~%S.%2f* would display *09~15~23.46*'
Expand Down
7 changes: 5 additions & 2 deletions src/traces/carpet/axis_attributes.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ var colorAttrs = require('../../components/color/attributes');
var axesAttrs = require('../../plots/cartesian/layout_attributes');
var overrideAll = require('../../plot_api/edit_types').overrideAll;

var FORMAT_LINK = require('../../constants/docs').FORMAT_LINK;
var DATE_FORMAT_LINK = require('../../constants/docs').TIME_FORMAT_LINK;

module.exports = {
color: {
valType: 'color',
Expand Down Expand Up @@ -297,9 +300,9 @@ module.exports = {
description: [
'Sets the tick label formatting rule using d3 formatting mini-languages',
'which are very similar to those in Python. For numbers, see:',
'https://github.com/d3/d3-format/blob/master/README.md#locale_format',
FORMAT_LINK,
'And for dates see:',
'https://github.com/d3/d3-time-format/blob/master/README.md#locale_format',
DATE_FORMAT_LINK,
'We add one item to d3\'s date formatter: *%{n}f* for fractional seconds',
'with n digits. For example, *2016-10-13 09:15:23.456* with tickformat',
'*%H~%M~%S.%2f* would display *09~15~23.46*'
Expand Down
4 changes: 3 additions & 1 deletion src/traces/contour/attributes.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ var filterOps = require('../../constants/filter_ops');
var COMPARISON_OPS2 = filterOps.COMPARISON_OPS2;
var INTERVAL_OPS = filterOps.INTERVAL_OPS;

var FORMAT_LINK = require('../../constants/docs').FORMAT_LINK;

var scatterLineAttrs = scatterAttrs.line;

module.exports = extendFlat({
Expand Down Expand Up @@ -181,7 +183,7 @@ module.exports = extendFlat({
description: [
'Sets the contour label formatting rule using d3 formatting',
'mini-language which is very similar to Python, see:',
'https://github.com/d3/d3-format/blob/master/README.md#locale_format.'
FORMAT_LINK
].join(' ')
},
operation: {
Expand Down
3 changes: 2 additions & 1 deletion src/traces/heatmap/attributes.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
var scatterAttrs = require('../scatter/attributes');
var hovertemplateAttrs = require('../../components/fx/hovertemplate_attributes');
var colorScaleAttrs = require('../../components/colorscale/attributes');
var FORMAT_LINK = require('../../constants/docs').FORMAT_LINK;

var extendFlat = require('../../lib/extend').extendFlat;

Expand Down Expand Up @@ -113,7 +114,7 @@ module.exports = extendFlat({
description: [
'Sets the hover text formatting rule using d3 formatting mini-languages',
'which are very similar to those in Python. See:',
'https://github.com/d3/d3-format/blob/master/README.md#locale_format'
FORMAT_LINK
].join(' ')
},
hovertemplate: hovertemplateAttrs()
Expand Down
5 changes: 3 additions & 2 deletions src/traces/indicator/attributes.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ var domainAttrs = require('../../plots/domain').attributes;
var axesAttrs = require('../../plots/cartesian/layout_attributes');
var templatedArray = require('../../plot_api/plot_template').templatedArray;
var delta = require('../../constants/delta.js');
var FORMAT_LINK = require('../../constants/docs').FORMAT_LINK;

var textFontAttrs = fontAttrs({
editType: 'plot',
Expand Down Expand Up @@ -168,7 +169,7 @@ module.exports = {
description: [
'Sets the value formatting rule using d3 formatting mini-language',
'which is similar to those of Python. See',
'https://github.com/d3/d3-format/blob/master/README.md#locale_format'
FORMAT_LINK
].join(' ')
},
font: extendFlat({}, textFontAttrs, {
Expand Down Expand Up @@ -232,7 +233,7 @@ module.exports = {
description: [
'Sets the value formatting rule using d3 formatting mini-language',
'which is similar to those of Python. See',
'https://github.com/d3/d3-format/blob/master/README.md#locale_format'
FORMAT_LINK
].join(' ')
},
increasing: {
Expand Down
4 changes: 3 additions & 1 deletion src/traces/sankey/attributes.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ var templatedArray = require('../../plot_api/plot_template').templatedArray;
var extendFlat = require('../../lib/extend').extendFlat;
var overrideAll = require('../../plot_api/edit_types').overrideAll;

var FORMAT_LINK = require('../../constants/docs').FORMAT_LINK;

var attrs = module.exports = overrideAll({
hoverinfo: extendFlat({}, plotAttrs.hoverinfo, {
flags: [],
Expand Down Expand Up @@ -50,7 +52,7 @@ var attrs = module.exports = overrideAll({
description: [
'Sets the value formatting rule using d3 formatting mini-language',
'which is similar to those of Python. See',
'https://github.com/d3/d3-format/blob/master/README.md#locale_format'
FORMAT_LINK
].join(' ')
},

Expand Down
6 changes: 4 additions & 2 deletions src/traces/table/attributes.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ var overrideAll = require('../../plot_api/edit_types').overrideAll;
var fontAttrs = require('../../plots/font_attributes');
var domainAttrs = require('../../plots/domain').attributes;

var FORMAT_LINK = require('../../constants/docs').FORMAT_LINK;

var attrs = module.exports = overrideAll({
domain: domainAttrs({name: 'table', trace: true}),

Expand Down Expand Up @@ -58,7 +60,7 @@ var attrs = module.exports = overrideAll({
description: [
'Sets the cell value formatting rule using d3 formatting mini-language',
'which is similar to those of Python. See',
'https://github.com/d3/d3-format/blob/master/README.md#locale_format'
FORMAT_LINK
].join(' ')
},

Expand Down Expand Up @@ -138,7 +140,7 @@ var attrs = module.exports = overrideAll({
description: [
'Sets the cell value formatting rule using d3 formatting mini-language',
'which is similar to those of Python. See',
'https://github.com/d3/d3-format/blob/master/README.md#locale_format'
FORMAT_LINK
].join(' ')
},

Expand Down

0 comments on commit 674f0b0

Please sign in to comment.