Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
_isAreaOpacityNumber(areaOpacity) {
const isNumber = snippet.isNumber(areaOpacity);
if (isNumber) {
if (areaOpacity < 0 || areaOpacity > 1) {
consoleUtil.print(GUIDE_AREACHART_AREAOPACITY_TYPE, 'warn');
}
} else if (!snippet.isUndefined(areaOpacity)) {
consoleUtil.print(GUIDE_AREACHART_AREAOPACITY_TYPE, 'error');
}
return isNumber;
}
}
render(paper, data) {
const {dimension, groupPositions, theme = {}, position, zeroTop, hasRangeData, options} = data;
const {dot: dotTheme = {}, colors} = theme;
const {spline, allowSelect, connectNulls, pointWidth, showDot, areaOpacity: areaOpacityOptions} = options;
const areaOpacity = this._isAreaOpacityNumber(areaOpacityOptions) ? areaOpacityOptions : 1;
const dotOpacity = showDot ? 1 : 0;
const borderStyle = this.makeBorderStyle(dotTheme.strokeColor, dotOpacity, dotTheme.strokeWidth);
const outDotStyle = this.makeOutDotStyle(dotOpacity, borderStyle);
const lineWidth = this.lineWidth = (snippet.isNumber(pointWidth) ? pointWidth : this.lineWidth);
this.paper = paper;
this.theme = theme;
this.isSpline = spline;
this.dimension = dimension;
this.position = position;
this.zeroTop = zeroTop;
this.hasRangeData = hasRangeData;
paper.setStart();
this.groupPaths = this._getAreaChartPath(groupPositions, null, connectNulls);
this.groupAreas = this._renderAreas(paper, this.groupPaths, colors, lineWidth, areaOpacity);
this.tooltipLine = this._renderTooltipLine(paper, dimension.height);
this.groupDots = this._renderDots(paper, groupPositions, colors, dotOpacity);
_getBoxplotTooltipTemplate(item) {
let template = tooltipTemplate.tplBoxplotChartDefault;
if (snippet.isNumber(item.outlierIndex)) {
template = tooltipTemplate.tplBoxplotChartOutlier;
item.label = item.outliers[item.outlierIndex].label;
}
return template;
}
_getFormattedValueForTooltip(valueType) {
const ratio = this.ratioMap[valueType];
const value = this[valueType];
const formattedValue = renderUtil.formatValue({
value,
formatFunctions: this.formatFunctions,
chartType: this.chartType,
areaType: 'tooltip',
valueType
});
return snippet.isNumber(ratio) ? formattedValue : value;
}
setPosition: function(el, x, y) {
x = util.isUndefined(x) ? 0 : x;
y = util.isUndefined(y) ? 0 : y;
el[posKey] = [x, y];
el.style.left = util.isNumber(x) ? (x + 'px') : x;
el.style.top = util.isNumber(y) ? (y + 'px') : y;
},
render(paper, data) {
const {dimension, groupPositions, theme, options, position} = data;
const {colors} = theme;
const opacity = options.showDot ? 1 : 0;
const isSpline = options.spline;
const lineWidth = this.lineWidth = (snippet.isNumber(options.pointWidth) ? options.pointWidth : this.lineWidth);
const borderStyle = this.makeBorderStyle(theme.dot.strokeColor, opacity, theme.dot.strokeWidth);
const outDotStyle = this.makeOutDotStyle(opacity, borderStyle);
let groupPaths;
if (isSpline) {
groupPaths = this._getSplineLinesPath(groupPositions, options.connectNulls);
} else {
groupPaths = this._getLinesPath(groupPositions, options.connectNulls);
}
this.paper = paper;
this.theme = theme;
this.isSpline = isSpline;
this.dimension = dimension;
this.position = position;
snippet.forEachArray(row, (cell, cellIndex) => {
const cellContent = (snippet.isNumber(cell) ? cell : `"${cell}"`);
csvText += cellContent;
if (cellIndex < lastCellIndex) {
csvText += itemDelimiter;
}
});
_makeSingleTooltipHtml(chartType, indexes) {
const {groupIndex} = indexes;
let data = this._findTooltipData(chartType, indexes);
let color = this._findTooltipColor(chartType, indexes, data);
if (predicate.isBoxplotChart(this.chartType) && snippet.isNumber(indexes.outlierIndex)) {
data.outlierIndex = indexes.outlierIndex;
}
if (this.colorSpectrum) {
color = this.colorSpectrum.getColor(data.colorRatio || data.ratio);
}
data.chartType = this.chartType;
data.cssText = `background-color: ${color}`;
data = Object.assign({
suffix: this.suffix
}, data);
data.valueTypes = this._makeHtmlForValueTypes(data, ['x', 'y', 'r']);
return this.templateFunc(data.category, data, this.getRawCategory(groupIndex));
}
renderDot(paper, position, color, opacity) {
const dotTheme = (this.theme && this.theme.dot) || {dot: {}};
let raphaelDot;
if (position) {
const dot = paper.circle(
position.left,
position.top,
(!snippet.isUndefined(dotTheme.radius)) ? dotTheme.radius : DEFAULT_DOT_RADIUS
);
const dotStyle = {
fill: dotTheme.fillColor || color,
'fill-opacity': snippet.isNumber(opacity) ? opacity : dotTheme.fillOpacity,
stroke: dotTheme.strokeColor || color,
'stroke-opacity': snippet.isNumber(opacity) ? opacity : dotTheme.strokeOpacity,
'stroke-width': dotTheme.strokeWidth
};
dot.attr(dotStyle);
raphaelDot = {
dot,
color
};
}
return raphaelDot;
}