Skip to content

Commit eb499d4

Browse files
committed
plotly#189 putting categorymode, categorylist and coercion into use
1 parent df9ee94 commit eb499d4

File tree

3 files changed

+12
-4
lines changed

3 files changed

+12
-4
lines changed

src/plot_api/plot_api.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -854,10 +854,10 @@ function doCalcdata(gd) {
854854
fullLayout._piecolormap = {};
855855
fullLayout._piedefaultcolorcount = 0;
856856

857-
// delete category list, if there is one, so we start over
857+
// initialize the category list, if there is one, so we start over
858858
// to be filled in later by ax.d2c
859859
for(i = 0; i < axList.length; i++) {
860-
axList[i]._categories = [];
860+
axList[i]._categories = axList[i]._initialCategories.slice();
861861
}
862862

863863
for(i = 0; i < fullData.length; i++) {

src/plots/cartesian/axis_defaults.js

+7
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,9 @@ var layoutAttributes = require('./layout_attributes');
2020
var handleTickValueDefaults = require('./tick_value_defaults');
2121
var handleTickMarkDefaults = require('./tick_mark_defaults');
2222
var handleTickLabelDefaults = require('./tick_label_defaults');
23+
var handleCategoryModeDefaults = require('./category_mode_defaults');
2324
var setConvert = require('./set_convert');
25+
var orderedCategories = require('./ordered_categories');
2426
var cleanDatum = require('./clean_datum');
2527
var axisIds = require('./axis_ids');
2628

@@ -72,6 +74,10 @@ module.exports = function handleAxisDefaults(containerIn, containerOut, coerce,
7274
}
7375
}
7476

77+
containerOut._initialCategories = axType === 'category' ?
78+
orderedCategories(letter, containerIn.categorymode, containerIn.categorylist, options.data) :
79+
[];
80+
7581
setConvert(containerOut);
7682

7783
var dfltColor = coerce('color');
@@ -105,6 +111,7 @@ module.exports = function handleAxisDefaults(containerIn, containerOut, coerce,
105111
handleTickValueDefaults(containerIn, containerOut, coerce, axType);
106112
handleTickLabelDefaults(containerIn, containerOut, coerce, axType, options);
107113
handleTickMarkDefaults(containerIn, containerOut, coerce, options);
114+
handleCategoryModeDefaults(containerIn, containerOut, coerce);
108115

109116
var lineColor = coerce2('linecolor', dfltColor),
110117
lineWidth = coerce2('linewidth'),

src/plots/cartesian/set_convert.js

+3-2
Original file line numberDiff line numberDiff line change
@@ -182,8 +182,9 @@ module.exports = function setConvert(ax) {
182182
// encounters them, ie all the categories from the
183183
// first data set, then all the ones from the second
184184
// that aren't in the first etc.
185-
// TODO: sorting options - do the sorting
186-
// progressively here as we insert?
185+
// it is assumed that this function is being invoked in the
186+
// already sorted category order; otherwise there would be
187+
// a disconnect between the array and the index returned
187188

188189
if(v !== null && v !== undefined && ax._categories.indexOf(v) === -1) {
189190
ax._categories.push(v);

0 commit comments

Comments
 (0)