-
Notifications
You must be signed in to change notification settings - Fork 3.1k
[#57688] Harmonize Backlogs module with Primer #21723
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: dev
Are you sure you want to change the base?
Changes from all commits
3885f1b
73d891d
3838dd6
8688dfd
cb72e00
741d016
16ca906
df2e2aa
3458c7b
f61614e
82f908b
bd05182
ed7f504
b1c67cc
5ad7d1d
03f3eb4
51a0a8b
099bc5a
dc9d9cb
b7bfbdd
4b3fb24
aaaa48f
2ceacbf
a90207c
61ff200
4e3f812
abcf52f
7d54e81
4d528a4
1697cb5
8767a8a
86cb8f2
60e1a62
caebb8c
822784b
9c3be80
c454b6c
df2b48b
2382e37
adc5b1b
e453132
b106a78
4351c53
654d256
4e104c4
81d5cca
3b3bdbd
4b93f5c
00d0b8c
b4970a0
eba6b1b
2118020
6dd4a22
b956deb
6edc43a
1fbd1f1
fc285cd
71508a2
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,18 @@ | ||
| <div class="position-relative mx-auto" style="height:60vh"> | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I am not a big fan of using these classes directly. Primer already changed them in the past and the advantage of system_arguments is that we don't have to care about this. Further, inline styles are also kind of an anti-pattern for me.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Primer's CSS is quite stable at this point, so I think it's ok to use utility classes directly. This was copy-pasted from the Budgets widget PR, so perhaps I can DRY that up once that is merged. |
||
| <canvas baseChart | ||
| [data]="lineChartData()" | ||
| [options]="lineChartOptions()" | ||
| [type]="'line'"></canvas> | ||
| </div> | ||
|
|
||
| @if (isDevMode) { | ||
| <hr/> | ||
|
|
||
| <details> | ||
| <summary>Debug</summary> | ||
| <code> | ||
| <pre>{{maxValue() }}</pre> | ||
| <pre>{{lineChartData() | json}}</pre> | ||
| </code> | ||
| </details> | ||
| } | ||
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -0,0 +1,86 @@ | ||||||
| //-- copyright | ||||||
| // OpenProject is an open source project management software. | ||||||
| // Copyright (C) the OpenProject GmbH | ||||||
| // | ||||||
| // This program is free software; you can redistribute it and/or | ||||||
| // modify it under the terms of the GNU General Public License version 3. | ||||||
| // | ||||||
| // OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows: | ||||||
| // Copyright (C) 2006-2013 Jean-Philippe Lang | ||||||
| // Copyright (C) 2010-2013 the ChiliProject Team | ||||||
| // | ||||||
| // This program is free software; you can redistribute it and/or | ||||||
| // modify it under the terms of the GNU General Public License | ||||||
| // as published by the Free Software Foundation; either version 2 | ||||||
| // of the License, or (at your option) any later version. | ||||||
| // | ||||||
| // This program is distributed in the hope that it will be useful, | ||||||
| // but WITHOUT ANY WARRANTY; without even the implied warranty of | ||||||
| // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||||||
| // GNU General Public License for more details. | ||||||
| // | ||||||
| // You should have received a copy of the GNU General Public License | ||||||
| // along with this program; if not, write to the Free Software | ||||||
| // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | ||||||
| // | ||||||
| // See COPYRIGHT and LICENSE files for more details. | ||||||
| //++ | ||||||
|
|
||||||
| import { JsonPipe } from '@angular/common'; | ||||||
| import { ChangeDetectionStrategy, Component, computed, inject, input } from '@angular/core'; | ||||||
| import { ChartData, ChartOptions } from 'chart.js'; | ||||||
| import { I18nService } from 'core-app/core/i18n/i18n.service'; | ||||||
| import PrimerColorsPlugin from 'core-app/shared/components/work-package-graphs/plugin.primer-colors'; | ||||||
| import { BaseChartDirective, provideCharts, withDefaultRegisterables } from 'ng2-charts'; | ||||||
| import { environment } from '../../../environments/environment'; | ||||||
|
|
||||||
| const BURNDOWN_Y_SCALE_MIN = 25; | ||||||
myabc marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||
|
|
||||||
| @Component({ | ||||||
| selector: 'op-burndown-chart', | ||||||
| templateUrl: './burndown-chart.component.html', | ||||||
| imports: [BaseChartDirective, JsonPipe], | ||||||
| providers: [provideCharts(withDefaultRegisterables(PrimerColorsPlugin))], | ||||||
| changeDetection: ChangeDetectionStrategy.OnPush | ||||||
| }) | ||||||
| export class BurndownChartComponent { | ||||||
| readonly isDevMode = !environment.production; | ||||||
| readonly i18n = inject(I18nService); | ||||||
| readonly chartData = input.required<string>(); | ||||||
|
|
||||||
| readonly lineChartData = computed<ChartData<'line'>>(() => { | ||||||
| const data = JSON.parse(this.chartData()) as ChartData<'line'>; | ||||||
| return data; | ||||||
| }); | ||||||
|
|
||||||
| readonly maxValue = computed(() => { | ||||||
| return this.lineChartData().datasets | ||||||
| .flatMap((dataset) => dataset.data) | ||||||
| .filter((item):item is number => typeof item === 'number') | ||||||
| .reduce((a, b) => Math.max(a, b), 0); | ||||||
| }); | ||||||
|
|
||||||
| readonly lineChartOptions = computed<ChartOptions<'line'>>(() => ({ | ||||||
| scales: { | ||||||
| x: { | ||||||
| title: { | ||||||
| display: true, | ||||||
| text: this.i18n.t('js.burndown.day') | ||||||
| } | ||||||
| }, | ||||||
| y: { | ||||||
| title: { | ||||||
| display: true, | ||||||
| text: this.i18n.t('js.burndown.points') | ||||||
| }, | ||||||
| suggestedMin: 0, | ||||||
| max: this.maxValue() + BURNDOWN_Y_SCALE_MIN | ||||||
|
||||||
| max: this.maxValue() + BURNDOWN_Y_SCALE_MIN | |
| suggestedMax: this.maxValue() + BURNDOWN_Y_SCALE_MIN |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ulferts thoughts?
Uh oh!
There was an error while loading. Please reload this page.