Skip to content

Commit

Permalink
fix log scale in radar chart - fixes #2078
Browse files Browse the repository at this point in the history
  • Loading branch information
junedchhipa committed Nov 29, 2020
1 parent a11a332 commit 0eabcdd
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions src/charts/Radar.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import DataLabels from '../modules/DataLabels'
import Filters from '../modules/Filters'
import Utils from '../utils/Utils'
import Helpers from './common/circle/Helpers'
import CoreUtils from '../modules/CoreUtils'

/**
* ApexCharts Radar Class for Spider/Radar Charts.
Expand Down Expand Up @@ -38,8 +39,15 @@ class Radar {
? w.globals.gridHeight + w.globals.goldenPadding * 1.5
: w.globals.gridWidth

this.maxValue = this.w.globals.maxY
this.minValue = this.w.globals.minY
this.isLog = w.config.yaxis[0].logarithmic

this.coreUtils = new CoreUtils(this.ctx)
this.maxValue = this.isLog
? this.coreUtils.getLogVal(w.globals.maxY, 0)
: w.globals.maxY
this.minValue = this.isLog
? this.coreUtils.getLogVal(this.w.globals.minY, 0)
: w.globals.minY

this.polygons = w.config.plotOptions.radar.polygons

Expand Down Expand Up @@ -112,6 +120,11 @@ class Radar {
s.forEach((dv, j) => {
const range = Math.abs(this.maxValue - this.minValue)
dv = dv + Math.abs(this.minValue)

if (this.isLog) {
dv = this.coreUtils.getLogVal(dv, 0)
}

this.dataRadiusOfPercent[i][j] = dv / range

this.dataRadius[i][j] = this.dataRadiusOfPercent[i][j] * this.size
Expand Down

0 comments on commit 0eabcdd

Please sign in to comment.