Skip to content

Commit

Permalink
Merge pull request #1830 from GSA/1824-data-viz-changes
Browse files Browse the repository at this point in the history
1824 data viz changes
  • Loading branch information
ccostino authored Aug 9, 2024
2 parents 75a69dc + 832932f commit 7d22f23
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 10 deletions.
6 changes: 3 additions & 3 deletions app/assets/javascripts/totalMessagesChart.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,14 @@
document.getElementById('message').innerText = `${sms_sent.toLocaleString()} sent / ${sms_remaining_messages.toLocaleString()} remaining`;

// Calculate minimum width for "Messages Sent" as 1% of the total chart width
var minSentPercentage = 0.01; // Minimum width as a percentage of total messages (1% in this case)
var minSentPercentage = 0.02; // Minimum width as a percentage of total messages (1% in this case)
var minSentValue = totalMessages * minSentPercentage;
var displaySent = Math.max(sms_sent, minSentValue);
var displayRemaining = totalMessages - displaySent;

var svg = d3.select("#totalMessageChart");
var width = chartContainer.clientWidth;
var height = 64;
var height = 48;

// Ensure the width is set correctly
if (width === 0) {
Expand Down Expand Up @@ -62,7 +62,7 @@
.attr("x", 0) // Initially set to 0, will be updated during animation
.attr("y", 0)
.attr("height", height)
.attr("fill", '#fa9441')
.attr("fill", '#C7CACE')
.attr("width", 0) // Start with width 0 for animation
.on('mouseover', function(event) {
tooltip.style('display', 'block')
Expand Down
6 changes: 5 additions & 1 deletion app/assets/sass/uswds/_data-visualization.scss
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

$delivered: color('blue-50v');
$pending: color('green-cool-40v');
$failed: color('orange-30v');
$failed: color('gray-cool-20');

.chart-container {
display: flex;
Expand All @@ -11,6 +11,10 @@ $failed: color('orange-30v');
}
}

#totalMessageChartContainer {
max-width: 600px;
}

.bar {
border-radius: units(0.5);
&.delivered, &.usage {
Expand Down
4 changes: 0 additions & 4 deletions app/templates/views/dashboard/dashboard.html
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,6 @@ <h2 id="chartTitle">Total Messages</h2>
<div id="message"></div>
</div>
<div id="totalMessageTable" class="margin-0"></div>
<p class="align-with-heading-copy margin-bottom-4">
What counts as 1 text message part?<br />
See <a class="usa-link" href="{{ url_for('.pricing') }}">Tracking usage</a>.
</p>

<h2 class="line-height-sans-2 margin-bottom-0 margin-top-4">
Activity snapshot
Expand Down
4 changes: 2 additions & 2 deletions tests/javascripts/totalMessagesChart.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ test('SVG element is correctly set up', done => {
setTimeout(() => {
const svg = document.getElementById('totalMessageChart');
expect(svg.getAttribute('width')).toBe('600');
expect(svg.getAttribute('height')).toBe('64');
expect(svg.getAttribute('height')).toBe('48');
done();
}, 1000); // Ensure enough time for the DOM updates
});
Expand Down Expand Up @@ -159,7 +159,7 @@ test('SVG bars are created and animated correctly', done => {

// Initial check
const sentBar = svg.querySelector('rect[fill="#0076d6"]');
const remainingBar = svg.querySelector('rect[fill="#fa9441"]');
const remainingBar = svg.querySelector('rect[fill="#C7CACE"]');

expect(sentBar).not.toBeNull();
expect(remainingBar).not.toBeNull();
Expand Down

0 comments on commit 7d22f23

Please sign in to comment.