Skip to content

Commit

Permalink
Merge pull request #2 from Flared/sebastien/increase-radial-chart-size
Browse files Browse the repository at this point in the history
Increase Radial Chart size
  • Loading branch information
sebd11 authored Nov 10, 2023
2 parents afc5939 + 402fbfb commit cca1a42
Show file tree
Hide file tree
Showing 9 changed files with 78 additions and 75 deletions.
2 changes: 1 addition & 1 deletion dist/apexcharts.amd.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/apexcharts.common.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/apexcharts.esm.js

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion dist/apexcharts.js
Original file line number Diff line number Diff line change
Expand Up @@ -20523,9 +20523,10 @@
});
if (w.globals.noData) return ret;
var elSeries = graphics.group();
var sizeOverride = this.w.config.plotOptions.radialBar.sizeOverride ? this.w.config.plotOptions.radialBar.sizeOverride : 2.05;
var centerY = this.defaultSize / 2;
var centerX = w.globals.gridWidth / 2;
var size = this.defaultSize / 2.05;
var size = this.defaultSize / sizeOverride;
if (!w.config.chart.sparkline.enabled) {
size = size - w.config.stroke.width - w.config.chart.dropShadow.blur;
}
Expand Down
2 changes: 1 addition & 1 deletion dist/apexcharts.min.js

Large diffs are not rendered by default.

17 changes: 8 additions & 9 deletions src/charts/Pie.js
Original file line number Diff line number Diff line change
Expand Up @@ -286,15 +286,15 @@ class Pie {
this.centerX,
this.centerY,
w.globals.radialSize / 1.25 +
w.config.plotOptions.pie.dataLabels.offset,
w.config.plotOptions.pie.dataLabels.offset,
(startAngle + angle / 2) % this.fullAngle
)
} else if (this.chartType === 'donut') {
labelPosition = Utils.polarToCartesian(
this.centerX,
this.centerY,
(w.globals.radialSize + this.donutSize) / 2 +
w.config.plotOptions.pie.dataLabels.offset,
w.config.plotOptions.pie.dataLabels.offset,
(startAngle + angle / 2) % this.fullAngle
)
}
Expand Down Expand Up @@ -361,7 +361,7 @@ class Pie {
if (
angle !== 0 &&
w.config.plotOptions.pie.dataLabels.minAngleToShowLabel <
sectorAngleArr[i]
sectorAngleArr[i]
) {
let formatter = w.config.dataLabels.formatter
if (formatter !== undefined) {
Expand Down Expand Up @@ -657,7 +657,7 @@ class Pie {
if (
Math.ceil(endDeg) >=
this.fullAngle +
(this.w.config.plotOptions.pie.startAngle % this.fullAngle)
(this.w.config.plotOptions.pie.startAngle % this.fullAngle)
) {
endDeg =
this.fullAngle +
Expand Down Expand Up @@ -760,8 +760,8 @@ class Pie {
const yLabel = helpers.drawYAxisTexts(
this.centerX,
this.centerY -
circleSize +
parseInt(w.config.yaxis[0].labels.style.fontSize, 10) / 2,
circleSize +
parseInt(w.config.yaxis[0].labels.style.fontSize, 10) / 2,
i,
yTexts[i]
)
Expand All @@ -786,9 +786,8 @@ class Pie {

let g = graphics.group({
class: 'apexcharts-datalabels-group',
transform: `translate(${opts.translateX ? opts.translateX : 0}, ${
opts.translateY ? opts.translateY : 0
}) scale(${w.config.plotOptions.pie.customScale})`,
transform: `translate(${opts.translateX ? opts.translateX : 0}, ${opts.translateY ? opts.translateY : 0
}) scale(${w.config.plotOptions.pie.customScale})`,
})

const showTotal = dataLabelsConfig.total.show
Expand Down
32 changes: 17 additions & 15 deletions src/charts/Radial.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class Radial extends Pie {

this.totalAngle = Math.abs(
w.config.plotOptions.radialBar.endAngle -
w.config.plotOptions.radialBar.startAngle
w.config.plotOptions.radialBar.startAngle
)

this.trackStartAngle = w.config.plotOptions.radialBar.track.startAngle
Expand Down Expand Up @@ -56,10 +56,12 @@ class Radial extends Pie {

let elSeries = graphics.group()

let sizeOverride = this.w.config.plotOptions.radialBar.sizeOverride ? this.w.config.plotOptions.radialBar.sizeOverride : 2.05

let centerY = this.defaultSize / 2
let centerX = w.globals.gridWidth / 2

let size = this.defaultSize / 2.05
let size = this.defaultSize / sizeOverride
if (!w.config.chart.sparkline.enabled) {
size = size - w.config.stroke.width - w.config.chart.dropShadow.blur
}
Expand Down Expand Up @@ -214,8 +216,8 @@ class Radial extends Pie {
this.margin * opts.series.length -
(strokeWidth *
parseInt(w.config.plotOptions.radialBar.track.strokeWidth, 10)) /
100 /
2
100 /
2

let hollowRadius = hollowSize - w.config.plotOptions.radialBar.hollow.margin

Expand Down Expand Up @@ -304,7 +306,7 @@ class Radial extends Pie {
prevEndAngle =
Math.round(
(this.totalAngle * Utils.negToZero(w.globals.previousPaths[i])) /
100
100
) + prevStartAngle
}

Expand Down Expand Up @@ -484,11 +486,11 @@ class Radial extends Pie {
) {
this.move(
opts.centerX -
loader.width / 2 +
w.config.plotOptions.radialBar.hollow.imageOffsetX,
loader.width / 2 +
w.config.plotOptions.radialBar.hollow.imageOffsetX,
opts.centerY -
loader.height / 2 +
w.config.plotOptions.radialBar.hollow.imageOffsetY
loader.height / 2 +
w.config.plotOptions.radialBar.hollow.imageOffsetY
)
})
g.add(image)
Expand All @@ -498,11 +500,11 @@ class Radial extends Pie {
) {
this.move(
opts.centerX -
imgWidth / 2 +
w.config.plotOptions.radialBar.hollow.imageOffsetX,
imgWidth / 2 +
w.config.plotOptions.radialBar.hollow.imageOffsetX,
opts.centerY -
imgHeight / 2 +
w.config.plotOptions.radialBar.hollow.imageOffsetY
imgHeight / 2 +
w.config.plotOptions.radialBar.hollow.imageOffsetY
)
this.size(imgWidth, imgHeight)
})
Expand All @@ -517,8 +519,8 @@ class Radial extends Pie {
return (
(opts.size *
(100 - parseInt(w.config.plotOptions.radialBar.hollow.size, 10))) /
100 /
(opts.series.length + 1) -
100 /
(opts.series.length + 1) -
this.margin
)
}
Expand Down
4 changes: 2 additions & 2 deletions src/modules/Core.js
Original file line number Diff line number Diff line change
Expand Up @@ -427,8 +427,8 @@ export default class Core {
let offsetY = cnf.chart.sparkline.enabled
? 0
: gl.axisCharts
? cnf.chart.parentHeightOffset
: 0
? cnf.chart.parentHeightOffset
: 0

gl.dom.Paper.node.parentNode.parentNode.style.minHeight =
gl.svgHeight + offsetY + 'px'
Expand Down
89 changes: 45 additions & 44 deletions types/apexcharts.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ declare class ApexCharts {
clearAnnotations(options?: any): void
dataURI(options?: { scale?: number, width?: number }): Promise<{ imgURI: string } | { blob: Blob }>
static exec(chartID: string, fn: string, ...args: Array<any>): any
static getChartByID(chartID: string): ApexCharts|undefined
static getChartByID(chartID: string): ApexCharts | undefined
static initOnLoad(): void
exports: {
cleanup(): string
Expand Down Expand Up @@ -100,22 +100,22 @@ type ApexChart = {
width?: string | number
height?: string | number
type?:
| 'line'
| 'area'
| 'bar'
| 'pie'
| 'donut'
| 'radialBar'
| 'scatter'
| 'bubble'
| 'heatmap'
| 'candlestick'
| 'boxPlot'
| 'radar'
| 'polarArea'
| 'rangeBar'
| 'rangeArea'
| 'treemap'
| 'line'
| 'area'
| 'bar'
| 'pie'
| 'donut'
| 'radialBar'
| 'scatter'
| 'bubble'
| 'heatmap'
| 'candlestick'
| 'boxPlot'
| 'radar'
| 'polarArea'
| 'rangeBar'
| 'rangeArea'
| 'treemap'
foreColor?: string
fontFamily?: string
background?: string
Expand Down Expand Up @@ -317,21 +317,21 @@ type ApexAxisChartSeries = {
group?: string
zIndex?: number
data:
| (number | null)[]
| {
x: any;
y: any;
fill?: ApexFill;
fillColor?: string;
strokeColor?: string;
meta?: any;
goals?: any;
barHeightOffset?: number;
columnWidthOffset?: number;
}[]
| [number, number | null][]
| [number, (number | null)[]][]
| number[][];
| (number | null)[]
| {
x: any;
y: any;
fill?: ApexFill;
fillColor?: string;
strokeColor?: string;
meta?: any;
goals?: any;
barHeightOffset?: number;
columnWidthOffset?: number;
}[]
| [number, number | null][]
| [number, (number | null)[]][]
| number[][];
}[]

type ApexNonAxisChartSeries = number[]
Expand Down Expand Up @@ -496,9 +496,9 @@ type ApexLocale = {
zoomOut?: string
pan?: string
reset?: string
exportToSVG?: string
exportToPNG?: string
exportToCSV?: string
exportToSVG?: string
exportToPNG?: string
exportToCSV?: string
}
}
}
Expand Down Expand Up @@ -691,6 +691,7 @@ type ApexPlotOptions = {
endAngle?: number
offsetX?: number
offsetY?: number
sizeOverride?: number
hollow?: {
margin?: number
size?: string
Expand Down Expand Up @@ -1015,7 +1016,7 @@ type ApexXAxis = {
offsetX?: number
offsetY?: number
format?: string
formatter?(value: string, timestamp?: number, opts?:any): string | string[]
formatter?(value: string, timestamp?: number, opts?: any): string | string[]
datetimeUTC?: boolean
datetimeFormatter?: {
year?: string
Expand All @@ -1027,14 +1028,14 @@ type ApexXAxis = {
}
}
group?: {
groups?: { title: string, cols: number }[],
style?: {
colors?: string | string[]
fontSize?: string
fontFamily?: string
fontWeight?: string | number
cssClass?: string
}
groups?: { title: string, cols: number }[],
style?: {
colors?: string | string[]
fontSize?: string
fontFamily?: string
fontWeight?: string | number
cssClass?: string
}
}
axisBorder?: {
show?: boolean
Expand Down

0 comments on commit cca1a42

Please sign in to comment.