8000 add options to include shapes and `newshape` in legends by archmoj · Pull Request #6653 · plotly/plotly.js · GitHub
[go: up one dir, main page]

Skip to content

add options to include shapes and newshape in legends #6653

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? 8000 Sign in to your account

Merged
merged 30 commits into from
Jul 25, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
6545353
register legends after shapes
archmoj Jun 27, 2023
786d9e6
add options to include shapes in legends
archmoj Jun 27, 2023
2d7d3da
test clicking shape legends
archmoj Jun 28, 2023
332a0dd
draftlog
archmoj Jun 28, 2023
8a0f60a
improve descriptions
archmoj Jun 28, 2023
f0c6b72
add comments to core.js about order of registering components
archmoj Jun 29, 2023
d3004c1
use hexagon2 for path symbols
archmoj Jun 29, 2023
51a28f9
use overrideAll in newshape and fix bundling issue
archmoj Jun 29, 2023
0fa6914
Merge branch 'master' into shape-legends
archmoj Jun 30, 2023
4728e86
Merge remote-tracking branch 'origin/master' into shape-legends
archmoj Jul 4, 2023
2f1f812
Merge remote-tracking branch 'origin/master' into shape-legends
archmoj Jul 5, 2023
3511eb4
test showing shapes in groups
archmoj Jul 5, 2023
8e181cc
rename vars to point to data updates
archmoj Jul 6, 2023
6c0ab2e
handle shape legends group click
archmoj Jul 6, 2023
7870720
avoid unrecognized messages on click
archmoj Jul 7, 2023
ef0fe6f
add grouptitle and handle click
archmoj Jul 7, 2023
2e77fc7
test legendrank
archmoj Jul 7, 2023
58b1cb1
mention traces and shapes order in legendrank description
archmoj Jul 7, 2023
3168078
test shape legends and groups in multiple legends
archmoj Jul 7, 2023
6343338
add name to newshape and improve descriptions
archmoj Jul 17, 2023
7bf5029
coerce newshape.name
archmoj Jul 17, 2023
948fd02
add name to newshapes when creating a new one
archm 8000 oj Jul 18, 2023
e5a600d
Update src/components/shapes/draw_newshape/attributes.js
archmoj Jul 18, 2023
5b02b62
more name appears fixes and update the schema
archmoj Jul 18, 2023
b35add8
fix shape.name updates via editing legends
archmoj Jul 18, 2023
6111aba
fix double click shape legends
archmoj Jul 19, 2023
5c0168c
simplify handling shape legends in click
archmoj Jul 20, 2023
15986b8
jasmine tests for editable shape legends
archmoj Jul 21, 2023
759dbb4
use update instead of restyle & relayout when updating shape legends
archmoj Jul 24, 2023
9123425
Merge remote-tracking branch 'origin/master' into shape-legends
archmoj Jul 25, 2023
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
Prev Previous commit
Next Next commit
use overrideAll in newshape and fix bundling issue
  • Loading branch information
archmoj committed Jun 29, 2023
commit 51a28f95e7adc7073ed79c0c7fbb439596dbb185
48 changes: 9 additions & 39 deletions src/components/shapes/draw_newshape/attributes.js
Original file line number Diff line number Diff line change
@@ -1,17 +1,16 @@
'use strict';

var overrideAll = require('../../../plot_api/edit_types').overrideAll;
var basePlotAttributes = require('../../../plots/attributes');
var fontAttrs = require('../../../plots/font_attributes');
var dash = require('../../drawing/attributes').dash;
var extendFlat = require('../../../lib/extend').extendFlat;
var shapeTexttemplateAttrs = require('../../../plots/template_attributes').shapeTexttemplateAttrs;
var shapeLabelTexttemplateVars = require('../label_texttemplate');


module.exports = {
module.exports = overrideAll({
newshape: {
visible: extendFlat({}, basePlotAttributes.visible, {
editType: 'none',
description: [
'Determines whether or not new shape is visible.',
'If *legendonly*, the shape is not drawn,',
Expand All @@ -23,15 +22,13 @@ module.exports = {
showlegend: {
valType: 'boolean',
dflt: false,
editType: 'none',
description: [
'Determines whether or not new',
'shape is shown in the legend.'
].join(' ')
},

legend: extendFlat({}, basePlotAttributes.legend, {
editType: 'none',
description: [
'Sets the reference to a legend to show new shape in.',
'References to these legends are *legend*, *legend2*, *legend3*, etc.',
Expand All @@ -41,7 +38,6 @@ module.exports = {
}),

legendgroup: extendFlat({}, basePlotAttributes.legendgroup, {
editType: 'none',
description: [
'Sets the legend group for new shape.',
'Traces and shapes part of the same legend group hide/show at the same time',
Expand All @@ -51,19 +47,15 @@ module.exports = {

legendgrouptitle: {
text: extendFlat({}, basePlotAttributes.legendgrouptitle.text, {
editType: 'none'
}),
font: fontAttrs({
editType: 'none',
description: [
'Sets this legend group\'s title font.'
].join(' '),
}),
editType: 'none',
})
},

legendrank: extendFlat({}, basePlotAttributes.legendrank, {
editType: 'none',
description: [
'Sets the legend rank for new shape.',
'Items and groups with smaller ranks are presented on top/left side while',
Expand All @@ -75,14 +67,12 @@ module.exports = {
}),

legendwidth: extendFlat({}, basePlotAttributes.legendwidth, {
editType: 'none',
description: 'Sets the width (in px or fraction) of the legend for new shape.',
}),

line: {
color: {
valType: 'color',
editType: 'none',
description: [
'Sets the line color.',
'By default uses either dark grey or white',
Expand All @@ -93,19 +83,15 @@ module.exports = {
valType: 'number',
min: 0,
dflt: 4,
editType: 'none',
description: 'Sets the line width (in px).'
},
dash: extendFlat({}, dash, {
dflt: 'solid',
editType: 'none'
}),
editType: 'none'
})
},
fillcolor: {
valType: 'color',
dflt: 'rgba(0,0,0,0)',
editType: 'none',
description: [
'Sets the color filling new shapes\' interior.',
'Please note that if using a fillcolor with alpha greater than half,',
Expand All @@ -117,7 +103,6 @@ module.exports = {
valType: 'enumerated',
values: ['evenodd', 'nonzero'],
dflt: 'evenodd',
editType: 'none',
description: [
'Determines the path\'s interior.',
'For more info please visit https://developer.mozilla.org/en-US/docs/Web/SVG/Attribute/fill-rule'
Expand All @@ -128,21 +113,18 @@ module.exports = {
min: 0,
max: 1,
dflt: 1,
editType: 'none',
description: 'Sets the opacity of new shapes.'
},
layer: {
valType: 'enumerated',
values: ['below', 'above'],
dflt: 'above',
editType: 'none',
description: 'Specifies whether new shapes are drawn below or above traces.'
},
drawdirection: {
valType: 'enumerated',
values: ['ortho', 'horizontal', 'vertical', 'diagonal'],
dflt: 'diagonal',
editType: 'none',
description: [
'When `dragmode` is set to *drawrect*, *drawline* or *drawcircle*',
'this limits the drag to be horizontal, vertical or diagonal.',
Expand All @@ -156,12 +138,10 @@ module.exports = {
text: {
valType: 'string',
dflt: '',
editType: 'none',
description: 'Sets the text to display with the new shape.'
},
texttemplate: shapeTexttemplateAttrs({newshape: true, editType: 'none'}, {keys: Object.keys(shapeLabelTexttemplateVars)}),
texttemplate: shapeTexttemplateAttrs({newshape: true}, {keys: Object.keys(shapeLabelTexttemplateVars)}),
font: fontAttrs({
editType: 'none',
description: 'Sets the new shape label text font.'
}),
textposition: {
Expand All @@ -172,7 +152,6 @@ module.exports = {
'bottom left', 'bottom center', 'bottom right',
'start', 'middle', 'end',
],
editType: 'none',
description: [
'Sets the position of the label text relative to the new shape.',
'Supported values for rectangles, circles and paths are',
Expand All @@ -186,7 +165,6 @@ module.exports = {
textangle: {
valType: 'angle',
dflt: 'auto',
editType: 'none',
description: [
'Sets the angle at which the label text is drawn',
'with respect to the horizontal. For lines, angle *auto*',
Expand All @@ -198,7 +176,6 @@ module.exports = {
valType: 'enumerated',
values: ['auto', 'left', 'center', 'right'],
dflt: 'auto',
editType: 'none',
description: [
'Sets the label\'s horizontal position anchor',
'This anchor binds the specified `textposition` to the *left*, *center*',
Expand All @@ -212,7 +189,6 @@ module.exports = {
yanchor: {
valType: 'enumerated',
values: ['top', 'middle', 'bottom'],
editType: 'none',
description: [
'Sets the label\'s vertical position anchor',
'This anchor binds the specified `textposition` to the *top*, *middle*',
Expand All @@ -227,29 +203,23 @@ module.exports = {
valType: 'number',
dflt: 3,
min: 0,
editType: 'none',
description: 'Sets padding (in px) between edge of label and edge of new shape.'
},
editType: 'none'
},
editType: 'none'
}
}
},

activeshape: {
fillcolor: {
valType: 'color',
dflt: 'rgb(255,0,255)',
editType: 'none',
description: 'Sets the color filling the active shape\' interior.'
},
opacity: {
valType: 'number',
min: 0,
max: 1,
dflt: 0.5,
editType: 'none',
description: 'Sets the opacity of the active shape.'
},
editType: 'none'
}
}
};
}, 'none', 'from-root');
5 changes: 2 additions & 3 deletions src/plot_api/edit_types.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
'use strict';

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

var traceOpts = {
valType: 'flaglist',
Expand Down
0