Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 26 additions & 2 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,30 @@ module.exports = {
},
rules: {
// Remove this when prettier 2.0 is out
'space-before-function-paren': 0 // Do not clash with Prettier
}
'space-before-function-paren': 0, // Do not clash with Prettier
// 'no-shadow': 1,
'no-undef': 1,
},
overrides: [
{
files: ['tests/unit/**/*.js'],
globals: {
describe: true,
it: true,
expect: true,
},
// env: {
// 'jest/globals': true,
// },
// plugins: ['jest', 'prettier'],
// rules: {
// 'jest/no-disabled-tests': 'error',
// 'jest/no-focused-tests': 'error',
// 'jest/no-identical-title': 'error',
// 'jest/no-jest-import': 'error',
// 'jest/prefer-to-have-length': 'error',
// 'jest/valid-expect': 'error',
// },
},
],
};
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
"build:umd": "rollup -w -c build/config.js --environment TARGET:web-umd-dev",
"build:amd": "webpack -p",
"lint": "eslint src/**/*.js tests/**/*.js --no-fix",
"test": "jest",
"test": "jest --testTimeout=30000",
"unit": "jest tests/unit/",
"e2e": "jest tests/e2e/"
},
Expand Down
34 changes: 10 additions & 24 deletions src/charts/Bar.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,6 @@ class Bar {
}

for (let i = 0, bc = 0; i < series.length; i++, bc++) {
let pathTo, pathFrom
let x,
y,
xDivision, // xDivision is the GRIDWIDTH divided by number of datapoints (columns)
Expand All @@ -99,7 +98,6 @@ class Bar {
this.visibleI = this.visibleI + 1
}

let strokeWidth = 0
let barHeight = 0
let barWidth = 0

Expand Down Expand Up @@ -132,12 +130,8 @@ class Bar {
class: 'apexcharts-datalabels'
})

for (
let j = 0, tj = w.globals.dataPoints;
j < w.globals.dataPoints;
j++, tj--
) {
strokeWidth = this.barHelpers.getStrokeWidth(i, j, realIndex)
for (let j = 0; j < w.globals.dataPoints; j++) {
const strokeWidth = this.barHelpers.getStrokeWidth(i, j, realIndex)

let paths = null
const pathsParams = {
Expand All @@ -149,8 +143,6 @@ class Bar {
},
x,
y,
pathTo,
pathFrom,
strokeWidth,
elSeries
}
Expand All @@ -172,8 +164,6 @@ class Bar {
barHeight = this.series[i][j] / this.yRatio[this.yaxisIndex]
}

pathTo = paths.pathTo
pathFrom = paths.pathFrom
y = paths.y
x = paths.x

Expand All @@ -191,8 +181,8 @@ class Bar {
pathFill,
j,
i,
pathFrom,
pathTo,
pathFrom: paths.pathFrom,
pathTo: paths.pathTo,
strokeWidth,
elSeries,
x,
Expand Down Expand Up @@ -265,8 +255,8 @@ class Bar {
i,
j,
realIndex,
pathFrom: pathFrom,
pathTo: pathTo,
pathFrom,
pathTo,
stroke: lineFill,
strokeWidth,
strokeLineCap: w.config.stroke.lineCap,
Expand Down Expand Up @@ -315,8 +305,6 @@ class Bar {
indexes,
barHeight,
strokeWidth,
pathTo,
pathFrom,
zeroW,
x,
y,
Expand All @@ -339,9 +327,9 @@ class Bar {

let barYPosition = y + barHeight * this.visibleI

pathTo = graphics.move(zeroW, barYPosition)
let pathTo = graphics.move(zeroW, barYPosition)

pathFrom = graphics.move(zeroW, barYPosition)
let pathFrom = graphics.move(zeroW, barYPosition)
if (w.globals.previousPaths.length > 0) {
pathFrom = this.getPreviousPath(realIndex, j)
}
Expand Down Expand Up @@ -424,8 +412,6 @@ class Bar {
x,
y,
xDivision,
pathTo,
pathFrom,
barWidth,
zeroH,
strokeWidth,
Expand Down Expand Up @@ -453,9 +439,9 @@ class Bar {

let barXPosition = x + barWidth * this.visibleI

pathTo = graphics.move(barXPosition, zeroH)
let pathTo = graphics.move(barXPosition, zeroH)

pathFrom = graphics.move(barXPosition, zeroH)
let pathFrom = graphics.move(barXPosition, zeroH)
if (w.globals.previousPaths.length > 0) {
pathFrom = this.getPreviousPath(realIndex, j)
}
Expand Down
27 changes: 7 additions & 20 deletions src/charts/BarStacked.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import CoreUtils from '../modules/CoreUtils'
import Bar from './Bar'
import Fill from '../modules/Fill'
import Graphics from '../modules/Graphics'
import Utils from '../utils/Utils'

Expand Down Expand Up @@ -60,7 +59,6 @@ class BarStacked extends Bar {
let y = 0

for (let i = 0, bc = 0; i < series.length; i++, bc++) {
let pathTo, pathFrom
let xDivision // xDivision is the GRIDWIDTH divided by number of datapoints (columns)
let yDivision // yDivision is the GRIDHEIGHT divided by number of datapoints (bars)
let zeroH // zeroH is the baseline where 0 meets y axis
Expand Down Expand Up @@ -93,7 +91,6 @@ class BarStacked extends Bar {
class: 'apexcharts-datalabels'
})

let strokeWidth = 0
let barHeight = 0
let barWidth = 0

Expand Down Expand Up @@ -127,16 +124,14 @@ class BarStacked extends Bar {
// }

for (let j = 0; j < w.globals.dataPoints; j++) {
strokeWidth = this.barHelpers.getStrokeWidth(i, j, realIndex)
const strokeWidth = this.barHelpers.getStrokeWidth(i, j, realIndex)

let paths = null
if (this.isHorizontal) {
paths = this.drawBarPaths({
indexes: { i, j, realIndex, bc },
barHeight,
strokeWidth,
pathTo,
pathFrom,
zeroW,
x,
y,
Expand All @@ -150,8 +145,6 @@ class BarStacked extends Bar {
x,
y,
xDivision,
pathTo,
pathFrom,
barWidth,
zeroH,
strokeWidth,
Expand All @@ -160,8 +153,6 @@ class BarStacked extends Bar {
barHeight = this.series[i][j] / this.yRatio[this.yaxisIndex]
}

pathTo = paths.pathTo
pathFrom = paths.pathFrom
y = paths.y
x = paths.x

Expand All @@ -175,8 +166,8 @@ class BarStacked extends Bar {
pathFill,
j,
i,
pathFrom,
pathTo,
pathFrom: paths.pathFrom,
pathTo: paths.pathTo,
strokeWidth,
elSeries,
x,
Expand Down Expand Up @@ -266,8 +257,6 @@ class BarStacked extends Bar {
indexes,
barHeight,
strokeWidth,
pathTo,
pathFrom,
zeroW,
x,
y,
Expand Down Expand Up @@ -352,8 +341,8 @@ class BarStacked extends Bar {
this.xArrjF.push(Math.abs(barXPosition - endingShape.newX))
this.xArrjVal.push(this.series[i][j])

pathTo = this.graphics.move(barXPosition, barYPosition)
pathFrom = this.graphics.move(barXPosition, barYPosition)
let pathTo = this.graphics.move(barXPosition, barYPosition)
let pathFrom = this.graphics.move(barXPosition, barYPosition)

if (w.globals.previousPaths.length > 0) {
pathFrom = this.bar.getPreviousPath(realIndex, j, false)
Expand Down Expand Up @@ -410,8 +399,6 @@ class BarStacked extends Bar {
x,
y,
xDivision,
pathTo,
pathFrom,
barWidth,
zeroH,
strokeWidth,
Expand Down Expand Up @@ -491,8 +478,8 @@ class BarStacked extends Bar {
this.yArrjF.push(Math.abs(barYPosition - endingShape.newY))
this.yArrjVal.push(this.series[i][j])

pathTo = this.graphics.move(barXPosition, barYPosition)
pathFrom = this.graphics.move(barXPosition, barYPosition)
let pathTo = this.graphics.move(barXPosition, barYPosition)
let pathFrom = this.graphics.move(barXPosition, barYPosition)
if (w.globals.previousPaths.length > 0) {
pathFrom = this.bar.getPreviousPath(realIndex, j, false)
}
Expand Down
29 changes: 8 additions & 21 deletions src/charts/CandleStick.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,7 @@ class CandleStick extends Bar {
class: 'apexcharts-candlestick-series apexcharts-plot-series'
})

for (let i = 0, bc = 0; i < series.length; i++, bc++) {
let pathTo, pathFrom
for (let i = 0; i < series.length; i++) {
let x,
y,
xDivision, // xDivision is the GRIDWIDTH divided by number of datapoints (columns)
Expand All @@ -53,7 +52,6 @@ class CandleStick extends Bar {
this.visibleI = this.visibleI + 1
}

let strokeWidth = 0
let barHeight = 0
let barWidth = 0

Expand All @@ -78,35 +76,26 @@ class CandleStick extends Bar {
class: 'apexcharts-datalabels'
})

for (
let j = 0, tj = w.globals.dataPoints;
j < w.globals.dataPoints;
j++, tj--
) {
strokeWidth = this.barHelpers.getStrokeWidth(i, j, realIndex)
for (let j = 0; j < w.globals.dataPoints; j++) {
const strokeWidth = this.barHelpers.getStrokeWidth(i, j, realIndex)

let color

let paths = this.drawCandleStickPaths({
indexes: {
i,
j,
realIndex,
bc
realIndex
},
x,
y,
xDivision,
pathTo,
pathFrom,
barWidth,
zeroH,
strokeWidth,
elSeries
})

pathTo = paths.pathTo
pathFrom = paths.pathFrom
y = paths.y
x = paths.x
color = paths.color
Expand Down Expand Up @@ -134,8 +123,8 @@ class CandleStick extends Bar {
lineFill,
j,
i,
pathFrom,
pathTo,
pathFrom: paths.pathFrom,
pathTo: paths.pathTo,
strokeWidth,
elSeries,
x,
Expand Down Expand Up @@ -164,8 +153,6 @@ class CandleStick extends Bar {
x,
y,
xDivision,
pathTo,
pathFrom,
barWidth,
zeroH,
strokeWidth
Expand Down Expand Up @@ -214,8 +201,8 @@ class CandleStick extends Bar {
l2 = zeroH - ohlc.l / yRatio
}

pathTo = graphics.move(barXPosition, zeroH)
pathFrom = graphics.move(barXPosition, y1)
let pathTo = graphics.move(barXPosition, zeroH)
let pathFrom = graphics.move(barXPosition, y1)
if (w.globals.previousPaths.length > 0) {
pathFrom = this.getPreviousPath(realIndex, j, true)
}
Expand Down
Loading