Skip to content

Commit

Permalink
xaxis color for bar charts fixes #39
Browse files Browse the repository at this point in the history
  • Loading branch information
junedchhipa committed Aug 22, 2018
1 parent 022f242 commit 3fba322
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 17 deletions.
2 changes: 1 addition & 1 deletion dist/apexcharts.min.js

Large diffs are not rendered by default.

15 changes: 1 addition & 14 deletions src/modules/axes/XAxis.js
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ class XAxis {
text: '',
textAnchor: 'middle',
fontSize: this.xaxisFontSize,
foreColor: this.xaxisForeColors[i],
foreColor: Array.isArray(this.xaxisForeColors) ? this.xaxisForeColors[i] : this.xaxisForeColors,
cssClass: 'apexcharts-xaxis-label ' + w.config.xaxis.labels.style.cssClass
})

Expand Down Expand Up @@ -400,19 +400,6 @@ class XAxis {
}
}

if (xAxisTexts.length > 0) {
let firstLabelPos = xAxisTexts[0].getBBox()
let lastLabelPos = xAxisTexts[xAxisTexts.length - 1].getBBox()

if (firstLabelPos.x < -25) {
xAxisTexts[0].parentNode.removeChild(xAxisTexts[0])
}

if (lastLabelPos.x + lastLabelPos.width > w.globals.gridWidth) {
xAxisTexts[xAxisTexts.length - 1].parentNode.removeChild(xAxisTexts[xAxisTexts.length - 1])
}
}

if (yAxisTextsInversed.length > 0) {
// truncate y axis in bar chart
let firstLabelPosX = yAxisTextsInversed[yAxisTextsInversed.length - 1].getBBox()
Expand Down
7 changes: 5 additions & 2 deletions src/modules/axes/YAxis.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,10 @@ class YAxis {
this.w = ctx.w

this.xaxisFontSize = this.w.config.xaxis.labels.style.fontSize
this.isBarHorizontal = !!((this.w.config.chart.type === 'bar' &&
this.w.config.plotOptions.bar.horizontal))
this.isBarHorizontal = !!(this.w.config.chart.type === 'bar' &&
this.w.config.plotOptions.bar.horizontal)

this.xaxisForeColors = this.w.config.xaxis.labels.style.colors

this.xAxisoffX = 0
if (this.w.config.xaxis.position === 'bottom') {
Expand Down Expand Up @@ -163,6 +165,7 @@ class YAxis {
y: this.xAxisoffX + w.config.xaxis.labels.offsetY + 30,
text: '',
textAnchor: 'middle',
foreColor: Array.isArray(this.xaxisForeColors) ? this.xaxisForeColors[realIndex] : this.xaxisForeColors,
fontSize: this.xaxisFontSize,
cssClass: 'apexcharts-xaxis-label ' + w.config.xaxis.labels.style.cssClass
})
Expand Down

0 comments on commit 3fba322

Please sign in to comment.