Skip to content

Commit

Permalink
Got the Project Moves chart working
Browse files Browse the repository at this point in the history
Signed-off-by: Chris Abraham <[email protected]>
  • Loading branch information
cjyabraham committed Oct 31, 2024
1 parent 4132e5c commit 5b4155b
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -262,30 +262,34 @@ function add_project_moves_chart_shortcode( $atts ) {
$current_year = (int) gmdate( 'Y' );

for ( $this_year = $start_year; $this_year <= $current_year; $this_year++ ) {
$archived_move[ $this_year ] = 0;
$archived_move[ $this_year ] = 0;
$incubating_move[ $this_year ] = 0;
$graduated_move[ $this_year ] = 0;
if ( $current_year == $this_year ) {
$graduated_background[] = 'rgb(193, 96, 220, .4)';
$incubating_background[] = 'rgb(240, 188, 0, .4)';
$archived_background[] = 'rgb(116, 116, 116, .4)';
$archived_background[] = 'rgb(116, 116, 116, .4)';
} else {
$graduated_background[] = 'rgb(193 96 220)';
$incubating_background[] = 'rgb(240, 188, 0)';
$archived_background[] = 'rgb(116, 116, 116)';
$archived_background[] = 'rgb(116, 116, 116)';
}
}

foreach ( $maturity_data as $md ) {
$md_year = (int) explode( '-', $md['accepted'] )[0];
if ( 2016 <= $md_year && $md_year <= $current_year ) {
if ( $md['graduated'] == $md['accepted'] ) {
$graduated_move[ $md_year ] += 1;
} elseif ( $md['incubating'] == $md['accepted'] ) {
$incubating_move[ $md_year ] += 1;
} else {
$archived_move[ $md_year ] += 1;
}
$accepted_year = (int) explode( '-', $md['accepted'] )[0];
$graduated_year = (int) explode( '-', $md['graduated'] )[0];
$incubating_year = (int) explode( '-', $md['incubating'] )[0];
$archived_year = (int) explode( '-', $md['archived'] )[0];

if ( 2016 <= $graduated_year && $graduated_year != $accepted_year ) {
$graduated_move[ $graduated_year ] += 1;
}
if ( 2016 <= $incubating_year && $incubating_year != $accepted_year ) {
$incubating_move[ $incubating_year ] += 1;
}
if ( 2016 <= $archived_year && $archived_year != $accepted_year ) {
$archived_move[ $archived_year ] += 1;
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,21 +28,21 @@ function projectMovesChart() {

const data = {
datasets: [
{
label: 'Sandbox',
data: project_sandbox_accepted_dates,
backgroundColor: chart_sandbox_background_colors
},
{
label: 'Incubating',
data: project_incubating_accepted_dates,
data: project_incubating_move_dates,
backgroundColor: chart_incubating_background_colors
},
{
label: 'Graduated',
data: project_graduated_accepted_dates,
data: project_graduated_move_dates,
backgroundColor: chart_graduated_background_colors
},
{
label: 'Archived',
data: project_archived_move_dates,
backgroundColor: chart_archived_background_colors
},
]
};

Expand Down Expand Up @@ -75,7 +75,7 @@ function projectMovesChart() {
y: {
title: {
display: true,
text: 'Projects Accepted into CNCF'
text: 'Projects Moves into Tier'
},
stacked: true
},
Expand Down

0 comments on commit 5b4155b

Please sign in to comment.