-
-
Notifications
You must be signed in to change notification settings - Fork 2k
Pie legend and showlegend per slice #7580
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
Changes from 20 commits
4fc0e3b
417ca2e
449598d
178959e
3f9143d
f9c65da
09bcc61
dd73d5a
71c01fb
177dca3
3e5e53f
ab11db2
73c531e
8f983db
a115e4e
ef93f2c
7ec5316
795b911
a73c4f9
2636c7b
b968041
51fc434
7aa08d8
cbe853b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| - Add support for arrays for the pie properties `showlegend` and `legend`, so that these can be configured per slice. [[#7580](https://github.com/plotly/plotly.js/pull/7580)] |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -86,10 +86,19 @@ exports.valObjectMeta = { | |
| boolean: { | ||
| description: 'A boolean (true/false) value.', | ||
| requiredOpts: [], | ||
| otherOpts: ['dflt'], | ||
| coerceFunction: function(v, propOut, dflt) { | ||
| if(v === true || v === false) propOut.set(v); | ||
| else propOut.set(dflt); | ||
| otherOpts: ['dflt', 'arrayOk'], | ||
| coerceFunction: function(v, propOut, dflt, opts) { | ||
| function isBoolean(value) { | ||
| return value === true || value === false; | ||
| } | ||
my-tien marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| if (opts.arrayOk && isArrayOrTypedArray(v) && v.length > 0 && v.every(isBoolean)) { | ||
|
||
| propOut.set(v); | ||
| } else if(isBoolean(v)) { | ||
| propOut.set(v); | ||
my-tien marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| } else { | ||
| propOut.set(dflt); | ||
| } | ||
| } | ||
my-tien marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| }, | ||
| number: { | ||
|
|
@@ -225,14 +234,19 @@ exports.valObjectMeta = { | |
| '\'geo\', \'geo2\', \'geo3\', ...' | ||
| ].join(' '), | ||
| requiredOpts: ['dflt'], | ||
| otherOpts: ['regex'], | ||
| otherOpts: ['regex', 'arrayOk'], | ||
| coerceFunction: function(v, propOut, dflt, opts) { | ||
| var regex = opts.regex || counterRegex(dflt); | ||
| if(typeof v === 'string' && regex.test(v)) { | ||
| function isSubplotId(value) { | ||
| return typeof value === 'string' && regex.test(value); | ||
| } | ||
my-tien marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| if (opts.arrayOk && isArrayOrTypedArray(v) && v.length > 0 && v.every(isSubplotId)) { | ||
| propOut.set(v); | ||
| return; | ||
| } else if(isSubplotId(v)) { | ||
| propOut.set(v); | ||
my-tien marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| } else { | ||
| propOut.set(dflt); | ||
| } | ||
| propOut.set(dflt); | ||
| }, | ||
| validateFunction: function(v, opts) { | ||
| var dflt = opts.dflt; | ||
|
|
||
my-tien marked this conversation as resolved.
Show resolved
Hide resolved
|
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,58 @@ | ||
| { | ||
| "data": [ | ||
| { | ||
| "labels": [ | ||
| "with", | ||
| "pie", | ||
| "multiple", | ||
| "hidden", | ||
| "legends", | ||
| "A", | ||
| "hidden too" | ||
| ], | ||
| "values": [3, 4, 2, 7, 1, 5, 8], | ||
| "type": "pie", | ||
| "showlegend": [true, true, true, false, true, true, false], | ||
| "legend": [ | ||
| "legend2", | ||
| "legend", | ||
| "legend2", | ||
| "legend4", | ||
| "legend3", | ||
| "legend", | ||
| "legend4" | ||
| ] | ||
| } | ||
| ], | ||
| "layout": { | ||
| "title": { | ||
| "text": "Test array version of 'showlegend' and 'legend'" | ||
| }, | ||
| "width": 500, | ||
| "height": 400, | ||
| "legend": { | ||
| "title": { | ||
| "text": "L1" | ||
| }, | ||
| "y": 1 | ||
| }, | ||
| "legend2": { | ||
| "title": { | ||
| "text": "L2" | ||
| }, | ||
| "y": 0.7 | ||
| }, | ||
| "legend3": { | ||
| "title": { | ||
| "text": "L3" | ||
| }, | ||
| "y": 0.2 | ||
| }, | ||
| "legend4": { | ||
| "title": { | ||
| "text": "L4" | ||
| }, | ||
| "y": 0 | ||
| } | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,57 @@ | ||
| { | ||
| "data": [ | ||
| { | ||
| "labels": [ | ||
| "with", | ||
| "multiple", | ||
| "hidden", | ||
| "legends", | ||
| "A", | ||
| "hidden too", | ||
| "pie" | ||
| ], | ||
| "values": [3, 2, 7, 1, 5, 8, 4], | ||
| "type": "pie", | ||
| "showlegend": [true, true, false, true, true, false], | ||
| "legend": [ | ||
| "legend2", | ||
| "legend2", | ||
| "legend4", | ||
| "legend3", | ||
| "legend", | ||
| "legend4" | ||
| ] | ||
| } | ||
| ], | ||
| "layout": { | ||
| "title": { | ||
| "text": "Test short array version of 'showlegend' and 'legend'" | ||
| }, | ||
| "width": 500, | ||
| "height": 400, | ||
| "legend": { | ||
| "title": { | ||
| "text": "L1" | ||
| }, | ||
| "y": 1 | ||
| }, | ||
| "legend2": { | ||
| "title": { | ||
| "text": "L2" | ||
| }, | ||
| "y": 0.7 | ||
| }, | ||
| "legend3": { | ||
| "title": { | ||
| "text": "L3" | ||
| }, | ||
| "y": 0.2 | ||
| }, | ||
| "legend4": { | ||
| "title": { | ||
| "text": "L4" | ||
| }, | ||
| "y": 0 | ||
| } | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,45 @@ | ||
| { | ||
| "data": [ | ||
| { | ||
| "label0": 1, | ||
| "type": "pie", | ||
| "values": [1, 2, 3, 4], | ||
| "showlegend": [true, false, true], | ||
| "legend": ["legend", "legend2", "legend3"] | ||
| } | ||
| ], | ||
| "layout": { | ||
| "title": { | ||
| "text": "Slice 2 is hidden, slice 4 is assigned<br>default legend and default visibility" | ||
| }, | ||
| "width": 400, | ||
| "height": 400, | ||
| "legend": { | ||
| "title": { | ||
| "text": "legend" | ||
| }, | ||
| "xanchor": "left", | ||
| "yanchor": "top", | ||
| "x": -0.2, | ||
| "y": -0.1 | ||
| }, | ||
| "legend2": { | ||
| "title": { | ||
| "text": "legend2: I should be hidden!" | ||
| }, | ||
| "xanchor": "left", | ||
| "yanchor": "top", | ||
| "x": 0.1, | ||
| "y": -0.1 | ||
| }, | ||
| "legend3": { | ||
| "title": { | ||
| "text": "legend3" | ||
| }, | ||
| "xanchor": "left", | ||
| "yanchor": "top", | ||
| "x": 0.4, | ||
| "y": -0.1 | ||
| } | ||
| } | ||
| } |
Uh oh!
There was an error while loading. Please reload this page.