Skip to content

Accept symbol numbers in string format #5073

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 3 commits into from
Aug 14, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
10 changes: 9 additions & 1 deletion src/components/drawing/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -220,8 +220,11 @@ Object.keys(SYMBOLDEFS).forEach(function(k) {
var n = symDef.n;
drawing.symbolList.push(
n,
String(n),
k,

n + 100,
String(n + 100),
k + '-open'
);
drawing.symbolNames[n] = k;
Expand All @@ -235,8 +238,11 @@ Object.keys(SYMBOLDEFS).forEach(function(k) {
} else {
drawing.symbolList.push(
n + 200,
String(n + 200),
k + '-dot',

n + 300,
String(n + 300),
Copy link
Collaborator

Choose a reason for hiding this comment

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

OIC this is needed for coerce to work... then we also need strings up above (L222, 224) for the n and n + 100 variants.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good call. Done in 5b7b18f.

k + '-open-dot'
);
}
Expand All @@ -250,7 +256,9 @@ var MAXSYMBOL = drawing.symbolNames.length;
var DOTPATH = 'M0,0.5L0.5,0L0,-0.5L-0.5,0Z';

drawing.symbolNumber = function(v) {
if(typeof v === 'string') {
if(isNumeric(v)) {
v = +v;
} else if(typeof v === 'string') {
var vbase = 0;
if(v.indexOf('-open') > 0) {
vbase = 100;
Expand Down
Binary file added test/image/baselines/symbols_string-numbers.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 3 additions & 3 deletions test/image/compare_pixels_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -102,10 +102,10 @@ if(allMock || argv.filter) {

var FLAKY_LIST = [
'treemap_coffee',
'treemap_textposition',
'treemap_with-without_values',
'treemap_sunburst_marker_colors',
'trace_metatext',
'gl3d_directions-streamtube1'
'gl3d_directions-streamtube1',
'gl3d_traces-with-opacity'
];

console.log('');
Expand Down
91 changes: 91 additions & 0 deletions test/image/mocks/symbols_string-numbers.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
{
"data": [
{
"y": [
0,
0,
0,
0
],
"type": "scatter",
"mode": "markers",
"marker": {
"line": { "width": 3, "color": "black" },
"size": 14,
"symbol": "1"
}
},
{
"y": [
1,
1,
1,
1
],
"type": "scatter",
"mode": "markers",
"marker": {
"line": { "width": 3, "color": "black" },
"size": 14,
"symbol": "101"
}
},
{
"y": [
2,
2,
2,
2
],
"type": "scatter",
"mode": "markers",
"marker": {
"line": { "width": 3, "color": "black" },
"size": 14,
"symbol": "201"
}
},
{
"y": [
3,
3,
3,
3
],
"type": "scatter",
"mode": "markers",
"marker": {
"line": { "width": 3, "color": "black" },
"size": 14,
"symbol": "301"
}
},
{
"y": [
4,
4,
4,
4
],
"type": "scatter",
"mode": "markers",
"marker": {
"line": { "width": 3, "color": "black" },
"size": 14,
"symbol": [
"1",
"101",
"201",
"301"
]
}
}
],
"layout": {
"title": {
"text": "Accept symbol numbers in string format"
},
"width": 400,
"height": 400
}
}
2 changes: 2 additions & 0 deletions test/jasmine/tests/mock_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -905,6 +905,7 @@ var list = [
'sunburst_values_colorscale',
'sunburst_with-without_values',
'sunburst_zero_values_textfit',
'symbols_string-numbers',
'table_latex_multitrace_scatter',
'table_plain_birds',
'table_ragged',
Expand Down Expand Up @@ -1952,6 +1953,7 @@ figs['sunburst_values'] = require('@mocks/sunburst_values');
figs['sunburst_values_colorscale'] = require('@mocks/sunburst_values_colorscale');
figs['sunburst_with-without_values'] = require('@mocks/sunburst_with-without_values');
figs['sunburst_zero_values_textfit'] = require('@mocks/sunburst_zero_values_textfit');
figs['symbols_string-numbers'] = require('@mocks/symbols_string-numbers');
figs['table_latex_multitrace_scatter'] = require('@mocks/table_latex_multitrace_scatter');
// figs['table_plain_birds'] = require('@mocks/table_plain_birds');
figs['table_ragged'] = require('@mocks/table_ragged');
Expand Down