-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
number like categories respect layout.autotypenumbers
#5880
base: master
Are you sure you want to change the base?
Changes from 16 commits
9caf482
536e6e9
5fc0ade
69ea57c
bf90246
b60fe18
6b47a05
89cbf11
b3896a2
8ac107a
536e513
0b48de5
e9901c2
74631d8
e8277a9
b53aa49
9128f4c
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,57 @@ | ||
{ | ||
"data":[{ | ||
"x": ["3", "1", "5", "2", "4", "6"], | ||
"y": ["6","7","8","2","3","4"] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What happens if we use numbers here? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. For this example, it looks the same, but if you try using numbers in the original issue, you get which means the coordinates in a shape refer to the index of the category on the axis if the shape coordinates are a number and the referenced axis is categorical. In this case the axes are categorical but the categories are numbers (see how they are spaced evenly on the axis even though the numbers are not evenly spaced) For context, this is the code: <!DOCTYPE html>
<html>
<head>
<meta http-equiv='Content-Type' content='text/html:charset=utf-8' />
<script src="../../build/plotly.js"></script>
</head>
<body>
<div id="tester"></div>
<script>
var layout = {
"xaxis": {
"type": "category",
"categoryarray": [
10, 25, 30, 40, 50, 60, 70
],
},
"shapes": [
{
"type": "rect",
"xref": "x",
"yref": "y",
"x0": 40,
"x1": 60,
"y0": 10,
"y1": 20,
"fillcolor": "rgba(45,180,135,0.3)",
}
]
};
var data = [
{
"x": [ 10, 30, 50, 70],
"y": [ 10, 20, 30, 40],
},
];
TESTER = document.getElementById('tester');
Plotly.newPlot( TESTER, data, layout );
</script>
</body>
</html> |
||
}], | ||
"layout":{ | ||
"xaxis": { | ||
"type": "category", | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Let's adjust formatting for these new mocks. |
||
"categoryarray": ["1", "2", "3", "4", "5", "6"] | ||
}, | ||
"yaxis": { | ||
"type": "category" | ||
}, | ||
"annotations": [ | ||
{ | ||
"text": "A", | ||
"x": "2", | ||
"y": 3.5 | ||
}, | ||
{ | ||
"text": "B", | ||
"x": 0.5, | ||
"y": "3" | ||
}, | ||
{ | ||
"text": "C", | ||
"x": 2, | ||
"y": "0" | ||
}, | ||
{ | ||
"text": "D", | ||
"x": "7", | ||
"y": 3 | ||
} | ||
], | ||
"shapes": [ | ||
{ | ||
"type": "line", | ||
"x0": 0.5, | ||
"x1": 0.5, | ||
"y0": 0, | ||
"y1": 1, | ||
"xref": "x domain", | ||
"yref": "y domain" | ||
}, | ||
{ | ||
"type": "line", | ||
"y0": 0.5, | ||
"y1": 0.5, | ||
"x0": 0, | ||
"x1": 1, | ||
"xref": "x domain", | ||
"yref": "y domain" | ||
} | ||
] | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
{ | ||
"data":[{ | ||
"x": ["3", "1", "5", "2", "4", "6"], | ||
"y": ["6","7","8","2","3","4"] | ||
}], | ||
"layout":{ | ||
"xaxis": { | ||
"type": "category", | ||
"categoryarray": ["1", "2", "3", "4", "5", "6"] | ||
}, | ||
"yaxis": { | ||
"type": "category" | ||
}, | ||
"images": [ | ||
{ | ||
"source": "https://images.plot.ly/language-icons/api-home/js-logo.png", | ||
"xref": "x", | ||
"yref": "y", | ||
"sizex": 1, | ||
"sizey": 1, | ||
"x": "2", | ||
"y": 3.5, | ||
"xanchor": "left", | ||
"yanchor": "top", | ||
"opacity": 0.4 | ||
}, | ||
{ | ||
"source": "https://images.plot.ly/language-icons/api-home/js-logo.png", | ||
"xref": "x", | ||
"yref": "y", | ||
"sizex": 1, | ||
"sizey": 1, | ||
"x": 0.5, | ||
"y": "3", | ||
"xanchor": "left", | ||
"yanchor": "top", | ||
"opacity": 0.6 | ||
}, | ||
{ | ||
"source": "https://images.plot.ly/language-icons/api-home/js-logo.png", | ||
"xref": "x", | ||
"yref": "y", | ||
"sizex": 1, | ||
"sizey": 1, | ||
"x": 2, | ||
"y": "0", | ||
"xanchor": "left", | ||
"yanchor": "top", | ||
"opacity": 0.8 | ||
|
||
}, | ||
{"source": "https://images.plot.ly/language-icons/api-home/js-logo.png", | ||
"xref": "x", | ||
"yref": "y", | ||
"sizex": 1, | ||
"sizey": 1, | ||
"x": "7", | ||
"y": 3, | ||
"xanchor": "left", | ||
"yanchor": "top", | ||
"opacity": 1 | ||
|
||
} | ||
], | ||
"shapes": [ | ||
{ | ||
"type": "line", | ||
"x0": 0.5, | ||
"x1": 0.5, | ||
"y0": 0, | ||
"y1": 1, | ||
"xref": "x domain", | ||
"yref": "y domain" | ||
}, | ||
{ | ||
"type": "line", | ||
"y0": 0.5, | ||
"y1": 0.5, | ||
"x0": 0, | ||
"x1": 1, | ||
"xref": "x domain", | ||
"yref": "y domain" | ||
} | ||
] | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
{ | ||
"data":[{ | ||
"x": ["3", "1", "5", "2", "4", "6"], | ||
"y": ["6","7","8","2","3","4"] | ||
}], | ||
"layout":{ | ||
"xaxis": { | ||
"type": "category", | ||
"categoryarray": ["1", "2", "3", "4", "5", "6"] | ||
}, | ||
"yaxis": { | ||
"type": "category" | ||
}, | ||
"shapes": [ | ||
{ | ||
"type": "rect", | ||
"x0": "2", | ||
"x1": "4", | ||
"y0": 3.5, | ||
"y1": 4.5, | ||
"line": {"color": "blue"} | ||
}, | ||
{ | ||
"type": "rect", | ||
"x0": 0.5, | ||
"x1": 1.5, | ||
"y0": "3", | ||
"y1": "4", | ||
"line": {"color": "red"} | ||
}, | ||
{ | ||
"type": "rect", | ||
"x0": 2, | ||
"x1": 4, | ||
"y0": "0", | ||
"y1": "4", | ||
"line": {"color": "green"} | ||
}, | ||
{ | ||
"type": "rect", | ||
"x0": "4", | ||
"x1": "7", | ||
"y0": 3, | ||
"y1": 4, | ||
"line": {"color": "yellow"} | ||
}, | ||
{ | ||
"type": "path", | ||
"path": "M0,5.5L3,4.5L1,3Z", | ||
"line": {"color": "orange"} | ||
}, | ||
{ | ||
"type": "line", | ||
"x0": 0.5, | ||
"x1": 0.5, | ||
"y0": 0, | ||
"y1": 1, | ||
"xref": "x domain", | ||
"yref": "y domain" | ||
}, | ||
{ | ||
"type": "line", | ||
"y0": 0.5, | ||
"y1": 0.5, | ||
"x0": 0, | ||
"x1": 1, | ||
"xref": "x domain", | ||
"yref": "y domain" | ||
} | ||
] | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you please elaborate why using
isNumeric
here is not possible?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
isNumeric
returnstrue
forisNumeric('1')
which we don't want. We want numeric string categories to have to use the indices.