apexcharts
Advanced tools
Comparing version 3.36.0 to 3.36.1
{ | ||
"name": "apexcharts", | ||
"version": "3.36.0", | ||
"version": "3.36.1", | ||
"description": "A JavaScript Chart Library", | ||
@@ -61,3 +61,3 @@ "repository": { | ||
"eslint-loader": "3.0.3", | ||
"eslint-plugin-import": "2.19.1", | ||
"eslint-plugin-import": "^2.26.0", | ||
"eslint-plugin-prettier": "3.1.2", | ||
@@ -64,0 +64,0 @@ "eslint-plugin-promise": "4.2.1", |
@@ -260,5 +260,2 @@ import Annotations from './modules/annotations/Annotations' | ||
} | ||
if (w.config.chart.type !== 'treemap') { | ||
me.axes.drawAxis(w.config.chart.type, graphData.xyRatios) | ||
} | ||
@@ -268,2 +265,6 @@ me.grid = new Grid(me) | ||
if (w.config.chart.type !== 'treemap') { | ||
me.axes.drawAxis(w.config.chart.type, elgrid) | ||
} | ||
me.annotations = new Annotations(me) | ||
@@ -277,4 +278,4 @@ me.annotations.drawImageAnnos() | ||
let xAxis = new XAxis(this.ctx) | ||
let yaxis = new YAxis(this.ctx) | ||
let xAxis = new XAxis(this.ctx, elgrid) | ||
let yaxis = new YAxis(this.ctx, elgrid) | ||
if (elgrid !== null) { | ||
@@ -307,2 +308,3 @@ xAxis.xAxisLabelCorrections(elgrid.xAxisTickWidth) | ||
} | ||
w.globals.dom.elGraphical.add(elgrid.elGridBorders) | ||
@@ -309,0 +311,0 @@ if (w.config.xaxis.crosshairs.position === 'front') { |
@@ -267,4 +267,4 @@ import CoreUtils from '../modules/CoreUtils' | ||
w.globals.gridHeight - | ||
this.baseLineY[this.yaxisIndex] + | ||
(this.isReversed ? w.globals.gridHeight : 0) - | ||
this.baseLineY[this.yaxisIndex] - | ||
(this.isReversed ? w.globals.gridHeight : 0) + | ||
(this.isReversed ? this.baseLineY[this.yaxisIndex] * 2 : 0) | ||
@@ -271,0 +271,0 @@ |
@@ -204,2 +204,22 @@ import Fill from '../../../modules/Fill' | ||
shouldApplyRadius(realIndex) { | ||
const w = this.w | ||
let applyRadius = false | ||
if (w.config.plotOptions.bar.borderRadius > 0) { | ||
if (w.config.chart.stacked) { | ||
if (w.config.plotOptions.bar.borderRadiusWhenStacked === 'last') { | ||
if (this.barCtx.lastActiveBarSerieIndex === realIndex) { | ||
applyRadius = true | ||
} | ||
} else { | ||
applyRadius = true | ||
} | ||
} else { | ||
applyRadius = true | ||
} | ||
} | ||
return applyRadius | ||
} | ||
barBackground({ j, i, x1, x2, y1, y2, elSeries }) { | ||
@@ -238,7 +258,5 @@ const w = this.w | ||
barXPosition, | ||
yRatio, | ||
y1, | ||
y2, | ||
strokeWidth, | ||
series, | ||
realIndex, | ||
@@ -255,15 +273,18 @@ i, | ||
let shapeOpts = { | ||
barWidth, | ||
strokeWidth, | ||
yRatio, | ||
barXPosition, | ||
y1, | ||
y2 | ||
let bW = barWidth | ||
let bXP = barXPosition | ||
if (w.config.series[realIndex].data[j]?.columnWidthOffset) { | ||
bXP = | ||
barXPosition - w.config.series[realIndex].data[j].columnWidthOffset / 2 | ||
bW = barWidth + w.config.series[realIndex].data[j].columnWidthOffset | ||
} | ||
let newPath = this.getRoundedBars(w, shapeOpts, series, i, j) | ||
const x1 = barXPosition | ||
const x2 = barXPosition + barWidth | ||
const x1 = bXP | ||
const x2 = bXP + bW | ||
// append tiny pixels to avoid exponentials (which cause issues in border-radius) | ||
y1 += 0.001 | ||
y2 += 0.001 | ||
let pathTo = graphics.move(x1, y1) | ||
@@ -279,8 +300,8 @@ let pathFrom = graphics.move(x1, y1) | ||
pathTo + | ||
graphics.line(x1, newPath.y2) + | ||
newPath.pathWithRadius + | ||
graphics.line(x2 - strokeWidth, newPath.y2) + | ||
sl + | ||
sl + | ||
'z' | ||
graphics.line(x1, y2) + | ||
graphics.line(x2 - strokeWidth, y2) + | ||
graphics.line(x2 - strokeWidth, y1) + | ||
(w.config.plotOptions.bar.borderRadiusApplication === 'around' | ||
? ' Z' | ||
: ' z') | ||
@@ -297,7 +318,17 @@ // the lines in pathFrom are repeated to equal it to the points of pathTo | ||
sl + | ||
graphics.line(x1, y1) | ||
graphics.line(x1, y1) + | ||
(w.config.plotOptions.bar.borderRadiusApplication === 'around' | ||
? ' Z' | ||
: ' z') | ||
if (this.shouldApplyRadius(realIndex)) { | ||
pathTo = graphics.roundPathCorners( | ||
pathTo, | ||
w.config.plotOptions.bar.borderRadius | ||
) | ||
} | ||
if (w.config.chart.stacked) { | ||
this.barCtx.yArrj.push(newPath.y2WithRadius) | ||
this.barCtx.yArrjF.push(Math.abs(y1 - newPath.y2WithRadius)) | ||
this.barCtx.yArrj.push(y2) | ||
this.barCtx.yArrjF.push(Math.abs(y1 - y2)) | ||
this.barCtx.yArrjVal.push(this.barCtx.series[i][j]) | ||
@@ -318,3 +349,2 @@ } | ||
strokeWidth, | ||
series, | ||
realIndex, | ||
@@ -331,15 +361,21 @@ i, | ||
let shapeOpts = { | ||
barHeight, | ||
strokeWidth, | ||
barYPosition, | ||
x2, | ||
x1 | ||
let bYP = barYPosition | ||
let bH = barHeight | ||
if (w.config.series[realIndex].data[j]?.barHeightOffset) { | ||
bYP = | ||
barYPosition - w.config.series[realIndex].data[j].barHeightOffset / 2 | ||
bH = barHeight + w.config.series[realIndex].data[j].barHeightOffset | ||
} | ||
let newPath = this.getRoundedBars(w, shapeOpts, series, i, j) | ||
const y1 = bYP | ||
const y2 = bYP + bH | ||
let pathTo = graphics.move(x1, barYPosition) | ||
let pathFrom = graphics.move(x1, barYPosition) | ||
// append tiny pixels to avoid exponentials (which cause issues in border-radius) | ||
x1 += 0.001 | ||
x2 += 0.001 | ||
let pathTo = graphics.move(x1, y1) | ||
let pathFrom = graphics.move(x1, y1) | ||
if (w.globals.previousPaths.length > 0) { | ||
@@ -349,14 +385,11 @@ pathFrom = this.barCtx.getPreviousPath(realIndex, j, false) | ||
const y1 = barYPosition | ||
const y2 = barYPosition + barHeight | ||
const sl = graphics.line(x1, y2 - strokeWidth) | ||
pathTo = | ||
pathTo + | ||
graphics.line(newPath.x2, y1) + | ||
newPath.pathWithRadius + | ||
graphics.line(newPath.x2, y2 - strokeWidth) + | ||
graphics.line(x2, y1) + | ||
graphics.line(x2, y2 - strokeWidth) + | ||
sl + | ||
sl + | ||
'z' | ||
(w.config.plotOptions.bar.borderRadiusApplication === 'around' | ||
? ' Z' | ||
: ' z') | ||
@@ -371,7 +404,17 @@ pathFrom = | ||
sl + | ||
graphics.line(x1, y1) | ||
graphics.line(x1, y1) + | ||
(w.config.plotOptions.bar.borderRadiusApplication === 'around' | ||
? ' Z' | ||
: ' z') | ||
if (this.shouldApplyRadius(realIndex)) { | ||
pathTo = graphics.roundPathCorners( | ||
pathTo, | ||
w.config.plotOptions.bar.borderRadius | ||
) | ||
} | ||
if (w.config.chart.stacked) { | ||
this.barCtx.xArrj.push(newPath.x2WithRadius) | ||
this.barCtx.xArrjF.push(Math.abs(x1 - newPath.x2WithRadius)) | ||
this.barCtx.xArrj.push(x2) | ||
this.barCtx.xArrjF.push(Math.abs(x1 - x2)) | ||
this.barCtx.xArrjVal.push(this.barCtx.series[i][j]) | ||
@@ -385,124 +428,2 @@ } | ||
/** getRoundedBars draws border radius for bars/columns | ||
* @memberof Bar | ||
* @param {object} w - chart context | ||
* @param {object} opts - consists several properties like barHeight/barWidth | ||
* @param {array} series - global primary series | ||
* @param {int} i - current iterating series's index | ||
* @param {int} j - series's j of i | ||
* @return {object} pathWithRadius - ending shape path string | ||
* newY/newX - which is calculated from existing x/y based on rounded border | ||
**/ | ||
getRoundedBars(w, opts, series, i, j) { | ||
let graphics = new Graphics(this.barCtx.ctx) | ||
let radius = 0 | ||
const borderRadius = w.config.plotOptions.bar.borderRadius | ||
const borderRadiusIsArray = Array.isArray(borderRadius) | ||
if (borderRadiusIsArray) { | ||
const radiusIndex = | ||
i > borderRadius.length - 1 ? borderRadius.length - 1 : i | ||
radius = borderRadius[radiusIndex] | ||
} else { | ||
radius = borderRadius | ||
} | ||
if ( | ||
w.config.chart.stacked && | ||
series.length > 1 && | ||
i !== this.barCtx.radiusOnSeriesNumber && | ||
!borderRadiusIsArray | ||
) { | ||
radius = 0 | ||
} | ||
if (this.barCtx.isHorizontal) { | ||
let pathWithRadius = '' | ||
let x2 = opts.x2 | ||
if (Math.abs(opts.x1 - opts.x2) < radius) { | ||
radius = Math.abs(opts.x1 - opts.x2) | ||
} | ||
if (typeof series[i][j] !== 'undefined' || series[i][j] !== null) { | ||
let inverse = this.barCtx.isReversed | ||
? series[i][j] > 0 | ||
: series[i][j] < 0 | ||
if (inverse) radius = radius * -1 | ||
x2 = x2 - radius | ||
pathWithRadius = | ||
graphics.quadraticCurve( | ||
x2 + radius, | ||
opts.barYPosition, | ||
x2 + radius, | ||
opts.barYPosition + (!inverse ? radius : radius * -1) | ||
) + | ||
graphics.line( | ||
x2 + radius, | ||
opts.barYPosition + | ||
opts.barHeight - | ||
opts.strokeWidth - | ||
(!inverse ? radius : radius * -1) | ||
) + | ||
graphics.quadraticCurve( | ||
x2 + radius, | ||
opts.barYPosition + opts.barHeight - opts.strokeWidth, | ||
x2, | ||
opts.barYPosition + opts.barHeight - opts.strokeWidth | ||
) | ||
} | ||
return { | ||
pathWithRadius, | ||
x2WithRadius: x2 + radius, | ||
x2 | ||
} | ||
} else { | ||
let pathWithRadius = '' | ||
let y2 = opts.y2 | ||
if (Math.abs(opts.y1 - opts.y2) < radius) { | ||
radius = Math.abs(opts.y1 - opts.y2) | ||
} | ||
if (typeof series[i][j] !== 'undefined' || series[i][j] !== null) { | ||
let inverse = series[i][j] < 0 | ||
if (inverse) radius = radius * -1 | ||
y2 = y2 + radius | ||
pathWithRadius = | ||
graphics.quadraticCurve( | ||
opts.barXPosition, | ||
y2 - radius, | ||
opts.barXPosition + (!inverse ? radius : radius * -1), | ||
y2 - radius | ||
) + | ||
graphics.line( | ||
opts.barXPosition + | ||
opts.barWidth - | ||
opts.strokeWidth - | ||
(!inverse ? radius : radius * -1), | ||
y2 - radius | ||
) + | ||
graphics.quadraticCurve( | ||
opts.barXPosition + opts.barWidth - opts.strokeWidth, | ||
y2 - radius, | ||
opts.barXPosition + opts.barWidth - opts.strokeWidth, | ||
y2 | ||
) | ||
} | ||
return { | ||
pathWithRadius, | ||
y2WithRadius: y2 - radius, | ||
y2 | ||
} | ||
} | ||
} | ||
checkZeroSeries({ series }) { | ||
@@ -509,0 +430,0 @@ let w = this.w |
@@ -53,5 +53,9 @@ import Animations from '../modules/Animations' | ||
// means we have a bubble | ||
finishRadius = w.globals.seriesZ[realIndex][dataPointIndex] / zRatio | ||
const bubble = w.config.plotOptions.bubble | ||
finishRadius = w.globals.seriesZ[realIndex][dataPointIndex] | ||
const bubble = w.config.plotOptions.bubble | ||
if (bubble.zScaling) { | ||
finishRadius /= zRatio | ||
} | ||
if (bubble.minBubbleRadius && finishRadius < bubble.minBubbleRadius) { | ||
@@ -58,0 +62,0 @@ finishRadius = bubble.minBubbleRadius |
@@ -190,2 +190,6 @@ import CoreUtils from '../CoreUtils' | ||
if (typeof y === 'string' && y.indexOf('px') > -1) { | ||
yP = parseFloat(y) | ||
} | ||
return yP | ||
@@ -236,2 +240,18 @@ } | ||
if ( | ||
type === 'x1' && | ||
typeof anno.x === 'string' && | ||
anno.x.indexOf('px') > -1 | ||
) { | ||
x1 = parseFloat(anno.x) | ||
} | ||
if ( | ||
type === 'x2' && | ||
typeof anno.x2 === 'string' && | ||
anno.x2.indexOf('px') > -1 | ||
) { | ||
x2 = parseFloat(anno.x2) | ||
} | ||
return type === 'x1' ? x1 : x2 | ||
@@ -238,0 +258,0 @@ } |
@@ -68,3 +68,2 @@ import Utils from '../../utils/Utils' | ||
} | ||
let textY = anno.label.position === 'top' ? 4 : w.globals.gridHeight | ||
@@ -75,2 +74,9 @@ let textRects = this.annoCtx.graphics.getTextRects( | ||
) | ||
let textY = | ||
anno.label.position === 'top' | ||
? 4 | ||
: anno.label.position === 'center' | ||
? w.globals.gridHeight / 2 + | ||
(anno.label.orientation === 'vertical' ? textRects.width / 2 : 0) | ||
: w.globals.gridHeight | ||
@@ -77,0 +83,0 @@ let elText = this.annoCtx.graphics.drawText({ |
@@ -64,3 +64,8 @@ import Helpers from './Helpers' | ||
} | ||
let textX = anno.label.position === 'right' ? w.globals.gridWidth : 0 | ||
let textX = | ||
anno.label.position === 'right' | ||
? w.globals.gridWidth | ||
: anno.label.position === 'center' | ||
? w.globals.gridWidth / 2 | ||
: 0 | ||
@@ -67,0 +72,0 @@ let elText = this.annoCtx.graphics.drawText({ |
@@ -10,8 +10,8 @@ import XAxis from './XAxis' | ||
drawAxis(type, xyRatios) { | ||
drawAxis(type, elgrid) { | ||
let gl = this.w.globals | ||
let cnf = this.w.config | ||
let xAxis = new XAxis(this.ctx) | ||
let yAxis = new YAxis(this.ctx) | ||
let xAxis = new XAxis(this.ctx, elgrid) | ||
let yAxis = new YAxis(this.ctx, elgrid) | ||
@@ -18,0 +18,0 @@ if (gl.axisCharts && type !== 'radar') { |
@@ -183,3 +183,3 @@ import CoreUtils from '../CoreUtils' | ||
if (w.config.grid.xaxis.lines.show) { | ||
this._drawGridLine({ x1, y1, x2, y2, parent }) | ||
this._drawGridLine({ i, x1, y1, x2, y2, xCount, parent }) | ||
} | ||
@@ -201,8 +201,9 @@ let y_2 = 0 | ||
let xAxis = new XAxis(this.ctx) | ||
xAxis.drawXaxisTicks(x1, y_2, this.elg) | ||
xAxis.drawXaxisTicks(x1, y_2, w.globals.dom.elGraphical) | ||
} | ||
} | ||
_drawGridLine({ x1, y1, x2, y2, parent }) { | ||
_drawGridLine({ i, x1, y1, x2, y2, xCount, parent }) { | ||
const w = this.w | ||
let excludeBorders = false | ||
@@ -215,2 +216,11 @@ const isHorzLine = parent.node.classList.contains( | ||
const offX = w.globals.barPadForNumericAxis | ||
if ((y1 === 0 && y2 === 0) || (x1 === 0 && x2 === 0)) { | ||
excludeBorders = true | ||
} | ||
if (y1 === w.globals.gridHeight && y2 === w.globals.gridHeight) { | ||
excludeBorders = true | ||
} | ||
if (w.globals.isBarHorizontal && (i === 0 || i === xCount - 1)) { | ||
excludeBorders = true | ||
} | ||
@@ -227,3 +237,8 @@ const graphics = new Graphics(this) | ||
line.node.classList.add('apexcharts-gridline') | ||
parent.add(line) | ||
if (excludeBorders) { | ||
this.elGridBorders.add(line) | ||
} else { | ||
parent.add(line) | ||
} | ||
} | ||
@@ -355,3 +370,11 @@ | ||
for (let i = 0; i < tA + (this.isRangeBar ? 1 : 0); i++) { | ||
this._drawGridLine({ x1, y1, x2, y2, parent: this.elgridLinesH }) | ||
this._drawGridLine({ | ||
i, | ||
xCount: tA + (this.isRangeBar ? 1 : 0), | ||
x1, | ||
y1, | ||
x2, | ||
y2, | ||
parent: this.elgridLinesH | ||
}) | ||
@@ -376,7 +399,15 @@ y1 = y1 + w.globals.gridHeight / (this.isRangeBar ? tA : tickAmount) | ||
if (w.config.grid.xaxis.lines.show) { | ||
this._drawGridLine({ x1, y1, x2, y2, parent: this.elgridLinesV }) | ||
this._drawGridLine({ | ||
i, | ||
xCount: xCount + 1, | ||
x1, | ||
y1, | ||
x2, | ||
y2, | ||
parent: this.elgridLinesV | ||
}) | ||
} | ||
let xAxis = new XAxis(this.ctx) | ||
xAxis.drawXaxisTicks(x1, 0, this.elg) | ||
xAxis.drawXaxisTicks(x1, 0, w.globals.dom.elGraphical) | ||
x1 = x1 + w.globals.gridWidth / xCount + 0.3 | ||
@@ -395,3 +426,11 @@ x2 = x1 | ||
for (let i = 0; i < w.globals.dataPoints + 1; i++) { | ||
this._drawGridLine({ x1, y1, x2, y2, parent: this.elgridLinesH }) | ||
this._drawGridLine({ | ||
i, | ||
xCount: w.globals.dataPoints + 1, | ||
x1, | ||
y1, | ||
x2, | ||
y2, | ||
parent: this.elgridLinesH | ||
}) | ||
@@ -418,2 +457,5 @@ y1 = y1 + w.globals.gridHeight / w.globals.dataPoints | ||
}) | ||
this.elGridBorders = graphics.group({ | ||
class: 'apexcharts-grid-borders' | ||
}) | ||
@@ -461,2 +503,3 @@ this.elg.add(this.elgridLinesH) | ||
el: this.elg, | ||
elGridBorders: this.elGridBorders, | ||
xAxisTickWidth: w.globals.gridWidth / xCount | ||
@@ -463,0 +506,0 @@ } |
@@ -11,4 +11,5 @@ import Graphics from '../Graphics' | ||
export default class XAxis { | ||
constructor(ctx) { | ||
constructor(ctx, elgrid) { | ||
this.ctx = ctx | ||
this.elgrid = elgrid | ||
this.w = ctx.w | ||
@@ -130,3 +131,5 @@ | ||
parseFloat(this.xaxisFontSize) + | ||
w.globals.xAxisLabelsHeight + | ||
(w.config.xaxis.title.position === 'bottom' | ||
? w.globals.xAxisLabelsHeight | ||
: -w.globals.xAxisLabelsHeight - 10) + | ||
w.config.xaxis.title.offsetY, | ||
@@ -160,3 +163,7 @@ text: w.config.xaxis.title.text, | ||
elXaxis.add(elHorzLine) | ||
if (this.elgrid && this.elgrid.elGridBorders) { | ||
this.elgrid.elGridBorders.add(elHorzLine) | ||
} else { | ||
elXaxis.add(elHorzLine) | ||
} | ||
} | ||
@@ -244,2 +251,6 @@ | ||
if (w.config.xaxis.title.text && w.config.xaxis.position === 'top') { | ||
offsetYCorrection += parseFloat(w.config.xaxis.title.style.fontSize) + 2 | ||
} | ||
if (!isLeafGroup) { | ||
@@ -449,4 +460,4 @@ offsetYCorrection = | ||
let elXAxisTitleText = graphics.drawText({ | ||
x: 0, | ||
y: w.globals.gridHeight / 2, | ||
x: w.config.yaxis[0].title.offsetX, | ||
y: w.globals.gridHeight / 2 + w.config.yaxis[0].title.offsetY, | ||
text: w.config.yaxis[0].title.text, | ||
@@ -483,3 +494,7 @@ textAnchor: 'middle', | ||
elYaxis.add(elVerticalLine) | ||
if (this.elgrid && this.elgrid.elGridBorders) { | ||
this.elgrid.elGridBorders.add(elVerticalLine) | ||
} else { | ||
elYaxis.add(elVerticalLine) | ||
} | ||
} | ||
@@ -486,0 +501,0 @@ |
@@ -12,4 +12,5 @@ import Graphics from '../Graphics' | ||
export default class YAxis { | ||
constructor(ctx) { | ||
constructor(ctx, elgrid) { | ||
this.ctx = ctx | ||
this.elgrid = elgrid | ||
this.w = ctx.w | ||
@@ -322,3 +323,8 @@ const w = this.w | ||
parent.add(elHorzLine) | ||
// in horizontal bars, we append axisBorder to elGridBorders element to avoid z-index issues | ||
if (this.elgrid && this.elgrid.elGridBorders) { | ||
this.elgrid.elGridBorders.add(elHorzLine) | ||
} else { | ||
parent.add(elHorzLine) | ||
} | ||
} | ||
@@ -325,0 +331,0 @@ } |
@@ -200,3 +200,3 @@ import Data from '../modules/Data' | ||
let universalBOM = '\uFEFF' | ||
let gSeries = w.globals.series.map((s,i)=>{ | ||
let gSeries = w.globals.series.map((s, i) => { | ||
return w.globals.collapsedSeriesIndices.indexOf(i) === -1 ? s : [] | ||
@@ -208,3 +208,7 @@ }) | ||
} | ||
const seriesMaxDataLength = Math.max(...series.map((s) => { return s.data ? s.data.length : 0 })) | ||
const seriesMaxDataLength = Math.max( | ||
...series.map((s) => { | ||
return s.data ? s.data.length : 0 | ||
}) | ||
) | ||
const dataFormat = new Data(this.ctx) | ||
@@ -271,2 +275,3 @@ | ||
if (columns.length && sI === 0) { | ||
// It's the first series. Go ahead and create the first row with header information. | ||
rows.push(columns.join(columnDelimiter)) | ||
@@ -276,4 +281,6 @@ } | ||
if (s.data) { | ||
s.data = s.data.length && s.data || getEmptyDataForCsvColumn() | ||
// Use the data we have, or generate a properly sized empty array with empty data if some data is missing. | ||
s.data = (s.data.length && s.data) || getEmptyDataForCsvColumn() | ||
for (let i = 0; i < s.data.length; i++) { | ||
// Reset the columns array so that we can start building columns for this row. | ||
columns = [] | ||
@@ -291,2 +298,3 @@ | ||
if (sI === 0) { | ||
// It's the first series. Also handle the category. | ||
columns.push( | ||
@@ -293,0 +301,0 @@ isTimeStamp(cat) |
@@ -17,2 +17,183 @@ import Animations from './Animations' | ||
/***************************************************************************** | ||
* * | ||
* SVG Path Rounding Function * | ||
* Copyright (C) 2014 Yona Appletree * | ||
* * | ||
* Licensed under the Apache License, Version 2.0 (the "License"); * | ||
* you may not use this file except in compliance with the License. * | ||
* You may obtain a copy of the License at * | ||
* * | ||
* http://www.apache.org/licenses/LICENSE-2.0 * | ||
* * | ||
* Unless required by applicable law or agreed to in writing, software * | ||
* distributed under the License is distributed on an "AS IS" BASIS, * | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * | ||
* See the License for the specific language governing permissions and * | ||
* limitations under the License. * | ||
* * | ||
*****************************************************************************/ | ||
/** | ||
* SVG Path rounding function. Takes an input path string and outputs a path | ||
* string where all line-line corners have been rounded. Only supports absolute | ||
* commands at the moment. | ||
* | ||
* @param pathString The SVG input path | ||
* @param radius The amount to round the corners, either a value in the SVG | ||
* coordinate space, or, if useFractionalRadius is true, a value | ||
* from 0 to 1. | ||
* @returns A new SVG path string with the rounding | ||
*/ | ||
roundPathCorners(pathString, radius) { | ||
function moveTowardsLength(movingPoint, targetPoint, amount) { | ||
var width = targetPoint.x - movingPoint.x | ||
var height = targetPoint.y - movingPoint.y | ||
var distance = Math.sqrt(width * width + height * height) | ||
return moveTowardsFractional( | ||
movingPoint, | ||
targetPoint, | ||
Math.min(1, amount / distance) | ||
) | ||
} | ||
function moveTowardsFractional(movingPoint, targetPoint, fraction) { | ||
return { | ||
x: movingPoint.x + (targetPoint.x - movingPoint.x) * fraction, | ||
y: movingPoint.y + (targetPoint.y - movingPoint.y) * fraction | ||
} | ||
} | ||
// Adjusts the ending position of a command | ||
function adjustCommand(cmd, newPoint) { | ||
if (cmd.length > 2) { | ||
cmd[cmd.length - 2] = newPoint.x | ||
cmd[cmd.length - 1] = newPoint.y | ||
} | ||
} | ||
// Gives an {x, y} object for a command's ending position | ||
function pointForCommand(cmd) { | ||
return { | ||
x: parseFloat(cmd[cmd.length - 2]), | ||
y: parseFloat(cmd[cmd.length - 1]) | ||
} | ||
} | ||
// Split apart the path, handing concatonated letters and numbers | ||
var pathParts = pathString.split(/[,\s]/).reduce(function(parts, part) { | ||
var match = part.match('([a-zA-Z])(.+)') | ||
if (match) { | ||
parts.push(match[1]) | ||
parts.push(match[2]) | ||
} else { | ||
parts.push(part) | ||
} | ||
return parts | ||
}, []) | ||
// Group the commands with their arguments for easier handling | ||
var commands = pathParts.reduce(function(commands, part) { | ||
if (parseFloat(part) == part && commands.length) { | ||
commands[commands.length - 1].push(part) | ||
} else { | ||
commands.push([part]) | ||
} | ||
return commands | ||
}, []) | ||
// The resulting commands, also grouped | ||
var resultCommands = [] | ||
if (commands.length > 1) { | ||
var startPoint = pointForCommand(commands[0]) | ||
// Handle the close path case with a "virtual" closing line | ||
var virtualCloseLine = null | ||
if (commands[commands.length - 1][0] == 'Z' && commands[0].length > 2) { | ||
virtualCloseLine = ['L', startPoint.x, startPoint.y] | ||
commands[commands.length - 1] = virtualCloseLine | ||
} | ||
// We always use the first command (but it may be mutated) | ||
resultCommands.push(commands[0]) | ||
for (var cmdIndex = 1; cmdIndex < commands.length; cmdIndex++) { | ||
var prevCmd = resultCommands[resultCommands.length - 1] | ||
var curCmd = commands[cmdIndex] | ||
// Handle closing case | ||
var nextCmd = | ||
curCmd == virtualCloseLine ? commands[1] : commands[cmdIndex + 1] | ||
// Nasty logic to decide if this path is a candidite. | ||
if ( | ||
nextCmd && | ||
prevCmd && | ||
prevCmd.length > 2 && | ||
curCmd[0] == 'L' && | ||
nextCmd.length > 2 && | ||
nextCmd[0] == 'L' | ||
) { | ||
// Calc the points we're dealing with | ||
var prevPoint = pointForCommand(prevCmd) | ||
var curPoint = pointForCommand(curCmd) | ||
var nextPoint = pointForCommand(nextCmd) | ||
// The start and end of the cuve are just our point moved towards the previous and next points, respectivly | ||
var curveStart, curveEnd | ||
curveStart = moveTowardsLength(curPoint, prevPoint, radius) | ||
curveEnd = moveTowardsLength(curPoint, nextPoint, radius) | ||
// Adjust the current command and add it | ||
adjustCommand(curCmd, curveStart) | ||
curCmd.origPoint = curPoint | ||
resultCommands.push(curCmd) | ||
// The curve control points are halfway between the start/end of the curve and | ||
// the original point | ||
var startControl = moveTowardsFractional(curveStart, curPoint, 0.5) | ||
var endControl = moveTowardsFractional(curPoint, curveEnd, 0.5) | ||
// Create the curve | ||
var curveCmd = [ | ||
'C', | ||
startControl.x, | ||
startControl.y, | ||
endControl.x, | ||
endControl.y, | ||
curveEnd.x, | ||
curveEnd.y | ||
] | ||
// Save the original point for fractional calculations | ||
curveCmd.origPoint = curPoint | ||
resultCommands.push(curveCmd) | ||
} else { | ||
// Pass through commands that don't qualify | ||
resultCommands.push(curCmd) | ||
} | ||
} | ||
// Fix up the starting point and restore the close path if the path was orignally closed | ||
if (virtualCloseLine) { | ||
var newStartPoint = pointForCommand( | ||
resultCommands[resultCommands.length - 1] | ||
) | ||
resultCommands.push(['Z']) | ||
adjustCommand(resultCommands[0], newStartPoint) | ||
} | ||
} else { | ||
resultCommands = commands | ||
} | ||
return resultCommands.reduce(function(str, c) { | ||
return str + c.join(' ') + ' ' | ||
}, '') | ||
} | ||
drawLine( | ||
@@ -156,7 +337,7 @@ x1, | ||
if (hORv === null) { | ||
line = ['L', x, y].join(' ') | ||
line = [' L', x, y].join(' ') | ||
} else if (hORv === 'H') { | ||
line = ['H', x].join(' ') | ||
line = [' H', x].join(' ') | ||
} else if (hORv === 'V') { | ||
line = ['V', y].join(' ') | ||
line = [' V', y].join(' ') | ||
} | ||
@@ -163,0 +344,0 @@ return line |
@@ -235,3 +235,6 @@ import Graphics from './Graphics' | ||
const hasData = s.data && s.data.length > 0 | ||
const hasData = | ||
s.data && | ||
s.data.length > 0 && | ||
w.globals.collapsedSeriesIndices.indexOf(index) === -1 | ||
@@ -238,0 +241,0 @@ return hasData && checkChartType() ? index : -1 |
@@ -355,2 +355,3 @@ import Utils from '../../utils/Utils' | ||
return buildRangeTooltipHTML({ | ||
...opts, | ||
color, | ||
@@ -367,2 +368,3 @@ seriesName, | ||
return buildRangeTooltipHTML({ | ||
...opts, | ||
color, | ||
@@ -369,0 +371,0 @@ seriesName, |
@@ -411,2 +411,4 @@ /** | ||
borderRadius: 0, | ||
borderRadiusApplication: 'around', // [around, end] | ||
borderRadiusWhenStacked: 'last', // [all, last] | ||
rangeBarOverlap: true, | ||
@@ -440,2 +442,3 @@ rangeBarGroupRows: false, | ||
bubble: { | ||
zScaling: true, | ||
minBubbleRadius: undefined, | ||
@@ -442,0 +445,0 @@ maxBubbleRadius: undefined |
@@ -321,2 +321,3 @@ // Typescript declarations for Apex class and module. | ||
y: any; | ||
fill?: ApexFill; | ||
fillColor?: string; | ||
@@ -326,2 +327,4 @@ strokeColor?: string; | ||
goals?: any; | ||
barHeightOffset?: number; | ||
columnWidthOffset?: number; | ||
}[] | ||
@@ -498,3 +501,3 @@ | [number, number | null][] | ||
exportToPNG?: string | ||
exportToCSV: string | ||
exportToCSV?: string | ||
} | ||
@@ -517,3 +520,5 @@ } | ||
distributed?: boolean | ||
borderRadius?: number | number[] | ||
borderRadius?: number; | ||
borderRadiusApplication?: 'around' | 'end'; | ||
borderRadiusWhenStacked?: 'all' | 'last'; | ||
rangeBarOverlap?: boolean | ||
@@ -551,2 +556,3 @@ rangeBarGroupRows?: boolean | ||
bubble?: { | ||
zScaling?: boolean | ||
minBubbleRadius?: number | ||
@@ -702,3 +708,3 @@ maxBubbleRadius?: number | ||
endAngle?: number | ||
background?: string | ||
background?: string | string[] | ||
strokeWidth?: string | ||
@@ -898,3 +904,3 @@ opacity?: number | ||
borderColor?: string | ||
dropShadow: ApexDropShadow | ||
dropShadow?: ApexDropShadow | ||
} | ||
@@ -1168,3 +1174,3 @@ dropShadow?: ApexDropShadow | ||
strokeWidth?: undefined | number | ||
dashArray: number | ||
dashArray?: number | ||
} | ||
@@ -1171,0 +1177,0 @@ |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Mixed license
License(Experimental) Package contains multiple licenses.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
4276509
69181
1