fix: Partial fix for #404 needs more work.
Better null value handling. Add option for filling zero/null values to maintain backwards compat.
This commit is contained in:
parent
9dce5cf5a8
commit
256649fbcc
@ -33,7 +33,9 @@ export default class BaseChart {
|
|||||||
options = deepClone(options);
|
options = deepClone(options);
|
||||||
|
|
||||||
this.parent =
|
this.parent =
|
||||||
typeof parent === "string" ? document.querySelector(parent) : parent;
|
typeof parent === "string"
|
||||||
|
? document.querySelector(parent)
|
||||||
|
: parent;
|
||||||
|
|
||||||
if (!(this.parent instanceof HTMLElement)) {
|
if (!(this.parent instanceof HTMLElement)) {
|
||||||
throw new Error("No `parent` element to render on was provided.");
|
throw new Error("No `parent` element to render on was provided.");
|
||||||
@ -44,7 +46,7 @@ export default class BaseChart {
|
|||||||
this.title = options.title || "";
|
this.title = options.title || "";
|
||||||
this.type = options.type || "";
|
this.type = options.type || "";
|
||||||
|
|
||||||
this.realData = this.prepareData(options.data);
|
this.realData = this.prepareData(options.data, options.config);
|
||||||
this.data = this.prepareFirstData(this.realData);
|
this.data = this.prepareFirstData(this.realData);
|
||||||
|
|
||||||
this.colors = this.validateColors(options.colors, this.type);
|
this.colors = this.validateColors(options.colors, this.type);
|
||||||
@ -52,9 +54,12 @@ export default class BaseChart {
|
|||||||
this.config = {
|
this.config = {
|
||||||
showTooltip: 1, // calculate
|
showTooltip: 1, // calculate
|
||||||
showLegend:
|
showLegend:
|
||||||
typeof options.showLegend !== "undefined" ? options.showLegend : 1,
|
typeof options.showLegend !== "undefined"
|
||||||
|
? options.showLegend
|
||||||
|
: 1,
|
||||||
isNavigable: options.isNavigable || 0,
|
isNavigable: options.isNavigable || 0,
|
||||||
animate: typeof options.animate !== "undefined" ? options.animate : 1,
|
animate:
|
||||||
|
typeof options.animate !== "undefined" ? options.animate : 0,
|
||||||
truncateLegends:
|
truncateLegends:
|
||||||
typeof options.truncateLegends !== "undefined"
|
typeof options.truncateLegends !== "undefined"
|
||||||
? options.truncateLegends
|
? options.truncateLegends
|
||||||
|
|||||||
@ -47,7 +47,7 @@ export function shuffle(array) {
|
|||||||
* @param {Boolean} start fill at start?
|
* @param {Boolean} start fill at start?
|
||||||
*/
|
*/
|
||||||
export function fillArray(array, count, element, start = false) {
|
export function fillArray(array, count, element, start = false) {
|
||||||
if (!element) {
|
if (element == undefined) {
|
||||||
element = start ? array[0] : array[array.length - 1];
|
element = start ? array[0] : array[array.length - 1];
|
||||||
}
|
}
|
||||||
let fillerArray = new Array(Math.abs(count)).fill(element);
|
let fillerArray = new Array(Math.abs(count)).fill(element);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user