Skip to content

Commit

Permalink
new prop - xaxis.overwriteCategories
Browse files Browse the repository at this point in the history
  • Loading branch information
junedchhipa committed May 18, 2021
1 parent 92dcb99 commit ee048fe
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 8 deletions.
7 changes: 1 addition & 6 deletions src/charts/common/bar/DataLabels.js
Original file line number Diff line number Diff line change
Expand Up @@ -364,12 +364,7 @@ export default class BarDataLabels {
})
}

if (val === 0 && w.config.chart.stacked) {
// in a stacked bar/column chart, 0 value should be neglected as it will overlap on the next element
text = ''
}

let valIsNegative = w.globals.series[i][j] <= 0
let valIsNegative = w.globals.series[i][j] < 0
let position = w.config.plotOptions.bar.dataLabels.position
if (w.config.plotOptions.bar.dataLabels.orientation === 'vertical') {
if (position === 'top') {
Expand Down
3 changes: 3 additions & 0 deletions src/modules/axes/XAxis.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ export default class XAxis {
this.xaxisLabels = w.globals.timescaleLabels.slice()
}

if (w.config.xaxis.overwriteCategories) {
this.xaxisLabels = w.config.xaxis.overwriteCategories
}
this.drawnLabels = []
this.drawnLabelsRects = []

Expand Down
4 changes: 2 additions & 2 deletions src/modules/axes/YAxis.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ export default class YAxis {
for (let i = tickAmount; i >= 0; i--) {
let val = labels[i]

val = lbFormatter(val, i)
val = lbFormatter(val, i, w)

let xPad = w.config.yaxis[realIndex].labels.padding
if (w.config.yaxis[realIndex].opposite && w.config.yaxis.length !== 0) {
Expand Down Expand Up @@ -226,7 +226,7 @@ export default class YAxis {
if (w.config.xaxis.labels.show) {
for (let i = tl ? 0 : tickAmount; tl ? i < tl : i >= 0; tl ? i++ : i--) {
let val = labels[i]
val = lbFormatter(val, i)
val = lbFormatter(val, i, w)

let x =
w.globals.gridWidth +
Expand Down
1 change: 1 addition & 0 deletions src/modules/settings/Options.js
Original file line number Diff line number Diff line change
Expand Up @@ -913,6 +913,7 @@ export default class Options {
convertedCatToNumeric: false, // internal property which should not be altered outside
offsetX: 0,
offsetY: 0,
overwriteCategories: undefined,
labels: {
show: true,
rotate: -45,
Expand Down
1 change: 1 addition & 0 deletions types/apexcharts.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -907,6 +907,7 @@ type ApexTooltip = {
type ApexXAxis = {
type?: 'category' | 'datetime' | 'numeric'
categories?: any;
overwriteCategories?: number[] | string[] | undefined;
offsetX?: number;
offsetY?: number;
sorted?: boolean;
Expand Down

0 comments on commit ee048fe

Please sign in to comment.