Skip to content

Commit

Permalink
Require at least 2 mataches for drawing cs rating graph
Browse files Browse the repository at this point in the history
  • Loading branch information
xPaw committed Sep 9, 2024
1 parent fb52b1e commit 84d0c48
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions scripts/community/achievements_cs2.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ const InitChart = ( container, initialData ) =>
const maxLengthInput = document.createElement( 'input' );
maxLengthInput.className = 'steamdb_achievements_csrating_graph_slider';
maxLengthInput.type = 'range';
maxLengthInput.min = 10;
maxLengthInput.min = 2;
maxLengthInput.max = initialData.length;
maxLengthInput.value = maxLength;
maxLengthInput.addEventListener( 'input', () =>
Expand Down Expand Up @@ -337,13 +337,23 @@ const FetchCSRating = async( profileUrl ) =>
summaryName.textContent = _t( 'achievements_csrating_name' );
summary.append( summaryName );

const chart = InitChart( summary, premierRows );
let chart = null;

if( premierRows.length > 1 )
{
chart = InitChart( summary, premierRows );
}

CreateCSRatingTable( summary, premierRows );

StartViewTransition( () =>
{
document.querySelector( '#mainContents' ).append( summary );
DrawChart( premierRows, -1, chart.canvas, chart.tooltip, chart.maxLength );

if( chart !== null )
{
DrawChart( premierRows, -1, chart.canvas, chart.tooltip, chart.maxLength );
}
} );
};

Expand Down

0 comments on commit 84d0c48

Please sign in to comment.