Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
function setDefaultOptions(options, chartContainer) {
options = util.extend({
editorChart: {},
chart: {},
chartExportMenu: {}
}, options);
let {width, height} = options.chart;
const isWidthUndefined = util.isUndefined(width);
const isHeightUndefined = util.isUndefined(height);
if (isWidthUndefined || isHeightUndefined) {
// if no width or height specified, set width and height to container width
const {
width: containerWidth
} = chartContainer.getBoundingClientRect();
options.chart.width = isWidthUndefined ? containerWidth : width;
options.chart.height = isHeightUndefined ? containerWidth : height;
}
options.editorChart.type = options.editorChart.type ? `${options.editorChart.type}Chart` : 'columnChart';
options.chartExportMenu.visible = options.chartExportMenu.visible || false;
return options;
}
function parseCode2ChartOption(optionCode) {
const reservedKeys = ['type', 'url'];
let options = {};
if (util.isUndefined(optionCode)) {
return options;
}
const optionLines = optionCode.split(REGEX_LINE_ENDING);
optionLines.forEach(line => {
let [keyString, ...values] = line.split(OPTION_DELIMITER);
let value = values.join(OPTION_DELIMITER);
keyString = keyString.trim();
if (value.length === 0) {
return;
}
try {
value = JSON.parse(value.trim());
} catch (e) {
value = value.trim();
function parseCode2ChartOption(optionCode) {
const reservedKeys = ['type', 'url'];
let options = {};
if (util.isUndefined(optionCode)) {
return options;
}
const optionLines = optionCode.split(REGEX_LINE_ENDING);
optionLines.forEach(line => {
let [keyString, ...values] = line.split(OPTION_DELIMITER);
let value = values.join(OPTION_DELIMITER);
keyString = keyString.trim();
if (value.length === 0) {
return;
}
try {
value = JSON.parse(value.trim());
} catch (e) {
value = value.trim();
result.push({
line: lineIndex,
ch: offsetlist[offsetIndex] - beforeLength
});
offsetIndex += 1;
if (util.isUndefined(offsetlist[offsetIndex])) {
return result;
}
}
beforeLength = currentLength;
}
while (!util.isUndefined(offsetlist[offsetIndex])) {
result.push({
line: lineIndex,
ch: currentLength - beforeLength
});
offsetIndex += 1;
}
return result;
}
_makeValidAngle(angle, defaultAngle) {
if (snippet.isUndefined(angle)) {
angle = defaultAngle;
} else if (angle < 0) {
angle = ANGLE_360 - (Math.abs(angle) % ANGLE_360);
} else if (angle > 0) {
angle = angle % ANGLE_360;
}
return angle;
}
_calculateLayerPosition(clientX, clientY, checkLimit) {
const {left, right, top} = this.mouseEventDetectorContainer.getBoundingClientRect();
const seriesPosition = this.positionMap.series;
const {expandSize} = this;
const layerPosition = {};
checkLimit = snippet.isUndefined(checkLimit) ? true : checkLimit;
if (checkLimit) {
const maxLeft = right - expandSize;
const minLeft = left + expandSize;
clientX = Math.min(Math.max(clientX, minLeft), maxLeft);
}
layerPosition.x = clientX - left + seriesPosition.left - chartConst.CHART_PADDING;
if (!snippet.isUndefined(clientY)) {
layerPosition.y = clientY - top + seriesPosition.top - chartConst.CHART_PADDING;
}
return layerPosition;
}
_showWedge(index) {
const {ratio, label} = this.mapModel.getDatum(index);
if (!snippet.isUndefined(ratio)) {
this.eventBus.fire('showWedge', ratio, label);
}
}
_makeValidAngle(angle, defaultAngle) {
if (snippet.isUndefined(angle)) {
angle = defaultAngle;
} else if (angle < 0) {
angle = ANGLE_360 - (Math.abs(angle) % ANGLE_360);
} else if (angle > 0) {
angle = angle % ANGLE_360;
}
return angle;
}
* @type {string}
*/
this.className = 'tui-chart-plot-area';
/**
* Data processor
* @type {DataProcessor}
*/
this.dataProcessor = params.dataProcessor;
/**
* Options
* @type {object}
*/
this.options = params.options || {};
this.options.showLine = snippet.isUndefined(this.options.showLine) ? true : this.options.showLine;
this.options.lines = this.options.lines || [];
this.options.bands = this.options.bands || [];
/**
* x axis type option
* @type {?string}
*/
this.xAxisTypeOption = params.xAxisTypeOption;
/**
* Theme
* @type {object}
*/
this.theme = params.theme || {};
/**