Skip to content

Commit 5a19499

Browse files
author
Jon M. Mease
committed
Rename categorylabels -> ticktext and categorylabelfont -> tickfont
for better consistency with other trace / axis types.
1 parent b1ef6c9 commit 5a19499

File tree

7 files changed

+28
-27
lines changed

7 files changed

+28
-27
lines changed

src/traces/parcats/attributes.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ module.exports = {
9494
description: 'Sets the font for the `dimension` labels.'
9595
}),
9696

97-
categorylabelfont: fontAttrs({
97+
tickfont: fontAttrs({
9898
editType: 'calc',
9999
description: 'Sets the font for the `category` labels.'
100100
}),
@@ -135,12 +135,12 @@ module.exports = {
135135
'Used with `categoryorder`.'
136136
].join(' ')
137137
},
138-
categorylabels: {
138+
ticktext: {
139139
valType: 'data_array',
140140
role: 'info',
141141
editType: 'calc',
142142
description: [
143-
'Sets alternative labels for the categories in this dimension.',
143+
'Sets alternative tick labels for the categories in this dimension.',
144144
'Only has an effect if `categoryorder` is set to *array*.',
145145
'Should be an array the same length as `categoryarray`',
146146
'Used with `categoryorder`.'

src/traces/parcats/calc.js

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@ module.exports = function calc(gd, trace) {
178178

179179
if(cats[catInd] === undefined) {
180180
var catValue = trace.dimensions[containerInd].categoryarray[catInd];
181-
var catLabel = trace.dimensions[containerInd].categorylabels[catInd];
181+
var catLabel = trace.dimensions[containerInd].ticktext[catInd];
182182
cats[catInd] = createCategoryModel(d, catInd, catValue, catLabel);
183183
}
184184

@@ -485,17 +485,17 @@ function validateCategoryProperties(dim, uniqueInfoDim) {
485485
// Update categoryarray
486486
dim.categoryarray = uniqueInfoDim.uniqueValues;
487487

488-
// Handle categorylabels
489-
if(dim.categorylabels === null || dim.categorylabels === undefined) {
490-
dim.categorylabels = [];
488+
// Handle ticktext
489+
if(dim.ticktext === null || dim.ticktext === undefined) {
490+
dim.ticktext = [];
491491
} else {
492492
// Shallow copy to avoid modifying input array
493-
dim.categorylabels = dim.categorylabels.slice();
493+
dim.ticktext = dim.ticktext.slice();
494494
}
495495

496-
// Extend categorylabels with elements from uniqueInfoDim.uniqueValues
497-
for(var i = dim.categorylabels.length; i < uniqueInfoDim.uniqueValues.length; i++) {
498-
dim.categorylabels.push(uniqueInfoDim.uniqueValues[i]);
496+
// Extend ticktext with elements from uniqueInfoDim.uniqueValues
497+
for(var i = dim.ticktext.length; i < uniqueInfoDim.uniqueValues.length; i++) {
498+
dim.ticktext.push(uniqueInfoDim.uniqueValues[i]);
499499
}
500500
}
501501

src/traces/parcats/defaults.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -64,10 +64,10 @@ function dimensionDefaults(dimensionIn, dimensionOut) {
6464
// coerce 'categoryarray' only in array order case
6565
if(order === 'array') {
6666
coerce('categoryarray');
67-
coerce('categorylabels');
67+
coerce('ticktext');
6868
} else {
6969
delete dimensionIn.categoryarray;
70-
delete dimensionIn.categorylabels;
70+
delete dimensionIn.ticktext;
7171
}
7272

7373
// cannot set 'categoryorder' to 'array' with an invalid 'categoryarray'
@@ -118,5 +118,5 @@ module.exports = function supplyDefaults(traceIn, traceOut, defaultColor, layout
118118
color: layout.font.color
119119
};
120120

121-
Lib.coerceFont(coerce, 'categorylabelfont', categoryfontDefault);
121+
Lib.coerceFont(coerce, 'tickfont', categoryfontDefault);
122122
};

src/traces/parcats/parcats.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1193,12 +1193,12 @@ function dragDimensionEnd(d) {
11931193
var sortedCategoryModels = d.model.categories.slice().sort(
11941194
function(a, b) { return a.displayInd - b.displayInd; });
11951195

1196-
// Get new categoryarray and categorylabels values
1196+
// Get new categoryarray and ticktext values
11971197
var newCategoryArray = sortedCategoryModels.map(function(v) { return v.categoryValue; });
11981198
var newCategoryLabels = sortedCategoryModels.map(function(v) { return v.categoryLabel; });
11991199

12001200
restyleData['dimensions[' + d.model.containerInd + '].categoryarray'] = [newCategoryArray];
1201-
restyleData['dimensions[' + d.model.containerInd + '].categorylabels'] = [newCategoryLabels];
1201+
restyleData['dimensions[' + d.model.containerInd + '].ticktext'] = [newCategoryLabels];
12021202
restyleData['dimensions[' + d.model.containerInd + '].categoryorder'] = 'array';
12031203
}
12041204
}
@@ -1475,7 +1475,7 @@ function createParcatsViewModel(graphDiv, layout, wrappedParcatsModel) {
14751475
bundlecolors: trace.bundlecolors,
14761476
sortpaths: trace.sortpaths,
14771477
labelfont: trace.labelfont,
1478-
categorylabelfont: trace.categorylabelfont,
1478+
categorylabelfont: trace.tickfont,
14791479
pathShape: pathShape,
14801480
dragDimension: null,
14811481
margin: margin,

test/image/mocks/parcats_fonts.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
{"label": "Two", "values": ["A", "B", "A", "B", "C", "C", "A", "B", "C"]},
88
{"label": "Three", "values": [11, 11, 11, 11, 11, 11, 11, 11, 11]}],
99
"labelfont": {"family": "Rockwell", "size": 20, "color": "gray"},
10-
"categorylabelfont": {"family": "Arial", "size": 10, "color": "firebrick"}
10+
"tickfont": {"family": "Arial", "size": 10, "color": "firebrick"}
1111
}
1212
],
1313
"layout": {

test/image/mocks/parcats_reordered.json

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,10 @@
33
{"type": "parcats",
44
"domain": {"x": [0.125, 0.625],"y": [0.25, 0.75]},
55
"dimensions": [
6-
{"label": "One", "values": [1, 1, 2, 1, 2, 1, 1, 2, 1], "displayindex": 0},
7-
{"label": "Two", "values": ["A", "B", "A", "B", "C", "C", "A", "B", "C"], "displayindex": 2,
8-
"categoryarray": ["B", "A", "C"]},
6+
{"label": "One", "values": [1, 1, 2, 1, 2, 1, 1, 2, 1],
7+
"displayindex": 0, "categoryarray": [1, 2], "ticktext": ["One", "Two"]},
8+
{"label": "Two", "values": ["A", "B", "A", "B", "C", "C", "A", "B", "C"],
9+
"displayindex": 2, "categoryarray": ["B", "A", "C"]},
910
{"label": "Three", "values": [11, 11, 11, 11, 11, 11, 11, 11, 11], "displayindex": 1}]}
1011
],
1112
"layout": {

test/jasmine/tests/parcats_test.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -355,13 +355,13 @@ describe('Dimension reordered parcats trace', function() {
355355
{dimensionInd: 0, displayInd: 0, dimensionLabel: 'One'});
356356

357357
checkCategoryCalc(gd, 0, 0, {
358-
categoryLabel: 1,
358+
categoryLabel: "One",
359359
dimensionInd: 0,
360360
categoryInd: 0,
361361
displayInd: 0});
362362

363363
checkCategoryCalc(gd, 0, 1, {
364-
categoryLabel: 2,
364+
categoryLabel: "Two",
365365
dimensionInd: 0,
366366
categoryInd: 1,
367367
displayInd: 1});
@@ -428,12 +428,12 @@ describe('Dimension reordered parcats trace', function() {
428428
{dimensionInd: 0, displayInd: 0, dimensionLabel: 'One'});
429429

430430
checkCategoryCalc(gd, 0, 0, {
431-
categoryLabel: 1,
431+
categoryLabel: "One",
432432
categoryInd: 0,
433433
displayInd: 0});
434434

435435
checkCategoryCalc(gd, 0, 1, {
436-
categoryLabel: 2,
436+
categoryLabel: "Two",
437437
categoryInd: 1,
438438
displayInd: 1});
439439

@@ -994,7 +994,7 @@ describe('Drag to reordered categories', function() {
994994
'dimensions[2].displayindex': 1,
995995
'dimensions[1].categoryorder': 'array',
996996
'dimensions[1].categoryarray': [['C', 'A', 'B' ]],
997-
'dimensions[1].categorylabels': [['C', 'A', 'B' ]]},
997+
'dimensions[1].ticktext': [['C', 'A', 'B' ]]},
998998
[0]]);
999999

10001000
restyleCallback.calls.reset();
@@ -1079,7 +1079,7 @@ describe('Drag to reordered categories', function() {
10791079
{
10801080
'dimensions[1].categoryorder': 'array',
10811081
'dimensions[1].categoryarray': [['C', 'A', 'B' ]],
1082-
'dimensions[1].categorylabels': [['C', 'A', 'B' ]]},
1082+
'dimensions[1].ticktext': [['C', 'A', 'B' ]]},
10831083
[0]]);
10841084

10851085
restyleCallback.calls.reset();

0 commit comments

Comments
 (0)