From 5b4155ba92af27825beff054580b56e89ad7060d Mon Sep 17 00:00:00 2001 From: Chris Abraham Date: Thu, 31 Oct 2024 14:55:40 -0400 Subject: [PATCH] Got the Project Moves chart working Signed-off-by: Chris Abraham --- .../includes/shortcodes/project-charts.php | 28 +++++++++++-------- .../js/on-demand/project-moves-chart.js | 16 +++++------ 2 files changed, 24 insertions(+), 20 deletions(-) diff --git a/web/wp-content/themes/cncf-twenty-two/includes/shortcodes/project-charts.php b/web/wp-content/themes/cncf-twenty-two/includes/shortcodes/project-charts.php index af8046f2..ac4d08b2 100644 --- a/web/wp-content/themes/cncf-twenty-two/includes/shortcodes/project-charts.php +++ b/web/wp-content/themes/cncf-twenty-two/includes/shortcodes/project-charts.php @@ -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; } } diff --git a/web/wp-content/themes/cncf-twenty-two/source/js/on-demand/project-moves-chart.js b/web/wp-content/themes/cncf-twenty-two/source/js/on-demand/project-moves-chart.js index 887747d8..8ce91455 100644 --- a/web/wp-content/themes/cncf-twenty-two/source/js/on-demand/project-moves-chart.js +++ b/web/wp-content/themes/cncf-twenty-two/source/js/on-demand/project-moves-chart.js @@ -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 + }, ] }; @@ -75,7 +75,7 @@ function projectMovesChart() { y: { title: { display: true, - text: 'Projects Accepted into CNCF' + text: 'Projects Moves into Tier' }, stacked: true },