Begin work on purging the range bucket type from the codebase
This commit is contained in:
parent
5fe11fda0d
commit
ac93a3342f
3 changed files with 4 additions and 33 deletions
|
|
@ -38,7 +38,6 @@ export const api = deepFreeze({
|
||||||
},
|
},
|
||||||
schemas: {
|
schemas: {
|
||||||
buckets: {
|
buckets: {
|
||||||
range: numberBucketSchema,
|
|
||||||
number: numberBucketSchema,
|
number: numberBucketSchema,
|
||||||
string: stringBucketSchema,
|
string: stringBucketSchema,
|
||||||
},
|
},
|
||||||
|
|
|
||||||
|
|
@ -61,7 +61,7 @@ export function validateBucketConfig(config) {
|
||||||
delete conf.choices;
|
delete conf.choices;
|
||||||
};
|
};
|
||||||
|
|
||||||
validator.validateConfig(conf);
|
validator.validateConfig?.(conf);
|
||||||
|
|
||||||
return conf;
|
return conf;
|
||||||
};
|
};
|
||||||
|
|
@ -74,7 +74,7 @@ const validators = {
|
||||||
opts.trim = true;
|
opts.trim = true;
|
||||||
opts.blank = false;
|
opts.blank = false;
|
||||||
},
|
},
|
||||||
validateConfig: (config) => {
|
transformConfig: (config) => {
|
||||||
if (config.choices.length === 0) {
|
if (config.choices.length === 0) {
|
||||||
delete config.choices;
|
delete config.choices;
|
||||||
config[`-=choices`] = null;
|
config[`-=choices`] = null;
|
||||||
|
|
@ -84,35 +84,6 @@ const validators = {
|
||||||
[BucketTypes.NUMBER]: {
|
[BucketTypes.NUMBER]: {
|
||||||
field: NumberField,
|
field: NumberField,
|
||||||
transformOptions: transformNumberFieldOptions,
|
transformOptions: transformNumberFieldOptions,
|
||||||
validateConfig: (config) => {
|
|
||||||
if (config.step != null && config.min == null) {
|
|
||||||
delete config.step;
|
|
||||||
config[`-=step`] = null;
|
|
||||||
};
|
|
||||||
if (
|
|
||||||
config.min != null
|
|
||||||
&& config.max != null
|
|
||||||
&& config.min > config.max
|
|
||||||
) {
|
|
||||||
throw new Error(`"min" must be less than "max"`);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
},
|
|
||||||
[BucketTypes.RANGE]: {
|
|
||||||
field: NumberField,
|
|
||||||
transformOptions: transformNumberFieldOptions,
|
|
||||||
validateConfig: (config) => {
|
|
||||||
if (config.min == null) {
|
|
||||||
throw new Error(`"min" must be defined for range buckets`);
|
|
||||||
};
|
|
||||||
if (config.max == null) {
|
|
||||||
throw new Error(`"max" must be defined for range buckets`);
|
|
||||||
};
|
|
||||||
if (config.min > config.max) {
|
|
||||||
throw new Error(`"min" must be less than "max"`);
|
|
||||||
}
|
|
||||||
config.step ??= 1;
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@ export function createDiceTable(size) {
|
||||||
return {
|
return {
|
||||||
name: `Dice/d${size}`,
|
name: `Dice/d${size}`,
|
||||||
buckets: {
|
buckets: {
|
||||||
type: `range`,
|
type: `number`,
|
||||||
min: 1,
|
min: 1,
|
||||||
max: size,
|
max: size,
|
||||||
step: 1,
|
step: 1,
|
||||||
|
|
@ -10,6 +10,7 @@ export function createDiceTable(size) {
|
||||||
graph: {
|
graph: {
|
||||||
type: `bar`,
|
type: `bar`,
|
||||||
stacked: true,
|
stacked: true,
|
||||||
|
showEmptyBuckets: true,
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue