OpenProject is the leading open source project management software for product, project and portfolio management. A powerful Jira alternative with agile planning, issue tracking, roadmaps, Gantt charts, time tracking, collaboration features, and more. Available on premises or in the cloud. ⭐ Star us on GitHub
Ruby agile-developmentangularbcfboardsbug-trackerganttgantt-chartifcissue-trackerjira-alternativekanbanopenprojectproduct-managementproject-managementproject-planningroadmaprubyscrumtimelineworkflows
add a new method to set the axis values
bsatarnejad1ba0b951dab5
diff --git a/frontend/src/app/modules/work-package-graphs/embedded/wp-embedded-graph.component.ts b/frontend/src/app/modules/work-package-graphs/embedded/wp-embedded-graph.component.tsindex e0baece6f87..f5b94e125e8 100644--- a/frontend/src/app/modules/work-package-graphs/embedded/wp-embedded-graph.component.ts+++ b/frontend/src/app/modules/work-package-graphs/embedded/wp-embedded-graph.component.ts@@ -99,52 +99,9 @@ export class WorkPackageEmbeddedGraphComponent {}};- let chartTypeDefaults:ChartOptions = {};-- if (this.chartType === 'horizontalBar') {- chartTypeDefaults = {- scales: {- xAxes: [{- stacked: true,- ticks: {- callback: (value:number) => {- if (Math.floor(value) === value) {- return value;- } else {- return 0;- }- }- }- }],- yAxes:- [{- stacked: true- }]- }- };- }-- if (this.chartType === 'bar') {- chartTypeDefaults = {- scales: {- yAxes: [{- stacked: true,- ticks: {- callback: (value:number) => {- if (Math.floor(value) === value) {- return value;- } else {- return 0;- }- }- }- }],- xAxes:- [{- stacked: true- }]- }- };+ let chartTypeDefaults:ChartOptions = {scales:{}};+ if (this.chartType === 'horizontalBar' || this.chartType === 'bar' ) {+ this.setChartAxesValues(chartTypeDefaults);}this.chartOptions = Object.assign({}, defaults, chartTypeDefaults, this.inputChartOptions);@@ -177,4 +134,35 @@ export class WorkPackageEmbeddedGraphComponent {this.chartHeight = '100%';}}++ // function to set ticks of axis+ private setChartAxesValues(chartOptions:ChartOptions) {++ let changeableValuesAxis = [{+ stacked: true,+ ticks: {+ callback: (value:number) => {+ if (Math.floor(value) === value) {+ return value;+ } else {+ return null;+ }+ }+ }+ }];++ let constantValuesAxis = [{+ stacked: true+ }];++ if (chartOptions.scales) {+ if (this.chartType === 'bar') {+ chartOptions.scales.yAxes = changeableValuesAxis;+ chartOptions.scales.xAxes = constantValuesAxis;+ } else if (this.chartType === 'horizontalBar') {+ chartOptions.scales.xAxes = changeableValuesAxis;+ chartOptions.scales.yAxes = constantValuesAxis;+ }+ }+ }}