Skip to content

Commit

Permalink
Ensure proper JS comments so they can be minified + formatting.
Browse files Browse the repository at this point in the history
  • Loading branch information
allinurl committed Apr 12, 2024
1 parent 964776c commit 5c4ce9b
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 13 deletions.
23 changes: 13 additions & 10 deletions resources/js/charts.js
Expand Up @@ -108,15 +108,15 @@ function WorldMap() {
if (svg.empty()) {
svg = selection.append('svg')
.attr('class', 'legend-svg')
.attr('width', width + margin.left + margin.right) // Adjust the width of the SVG
.attr('width', width + margin.left + margin.right)
.attr('height', legendHeight + 2 * legendPadding);
}

let legend = svg.select('.legend');
if (legend.empty()) {
legend = svg.append('g')
.attr('class', 'legend')
.attr('transform', `translate(${margin.left}, ${legendPadding})`); // Adjust the position of the legend
.attr('transform', `translate(${margin.left}, ${legendPadding})`);
}

const legendData = colorScale.quantiles();
Expand All @@ -126,9 +126,9 @@ function WorldMap() {

legendRects.enter().append('rect')
.merge(legendRects)
.attr('x', (d, i) => (i * (innerW())) / legendData.length) // Adjust the x attribute
.attr('x', (d, i) => (i * (innerW())) / legendData.length)
.attr('y', 0)
.attr('width', (innerW()) / legendData.length) // Adjust the width of the rectangles
.attr('width', (innerW()) / legendData.length)
.attr('height', legendHeight)
.style('fill', d => colorScale(d));

Expand All @@ -139,7 +139,7 @@ function WorldMap() {

legendTexts.enter().append('text')
.merge(legendTexts)
.attr('x', (d, i) => (i * (innerW())) / legendData.length) // Adjust the x attribute
.attr('x', (d, i) => (i * (innerW())) / legendData.length)
.attr('y', legendHeight + legendPadding)
.text(d => Math.round(d))
.style('font-size', '10px')
Expand Down Expand Up @@ -167,10 +167,11 @@ function WorldMap() {
let country = svg.select('g').selectAll('.country')
.data(countries);

// set initial opacity to 0 for entering elements
let countryEnter = country.enter().append('path')
.attr('class', 'country')
.attr('d', path)
.attr('opacity', 0); // set initial opacity to 0 for entering elements
.attr('opacity', 0);

country = countryEnter.merge(country)
.on('mouseover', function(event, d) {
Expand All @@ -187,19 +188,21 @@ function WorldMap() {
const countryData = dataByName[d.id];
return countryData ? colorScale(countryData[metric]) : '#cccccc54';
})
.attr('opacity', 1); // animate opacity to 1
.attr('opacity', 1);

country.exit()
.transition().duration(500)
.attr('opacity', 0) // animate opacity to 0
.attr('opacity', 0)
.remove();

}

function setBounds(projection, maxLat) {
const [yaw] = projection.rotate();
const xymax = projection([-yaw + 180 - 1e-6, -maxLat]); // Top left corner
const xymin = projection([-yaw - 180 + 1e-6, maxLat]); // Bottom right corner
// Top left corner
const xymax = projection([-yaw + 180 - 1e-6, -maxLat]);
// Bottom right corner
const xymin = projection([-yaw - 180 + 1e-6, maxLat]);
return [xymin, xymax];
}

Expand Down
5 changes: 2 additions & 3 deletions src/util.c
Expand Up @@ -96,9 +96,8 @@ static const char *codes[1000] = {
[500] = STATUS_CODE_500, STATUS_CODE_501, STATUS_CODE_502, STATUS_CODE_503, STATUS_CODE_504,
[505] = STATUS_CODE_505,
[509] = STATUS_CODE_509,
[520] =
STATUS_CODE_520, STATUS_CODE_521, STATUS_CODE_522, STATUS_CODE_523, STATUS_CODE_524,
STATUS_CODE_525, STATUS_CODE_526, STATUS_CODE_527, STATUS_CODE_529,
[520] = STATUS_CODE_520, STATUS_CODE_521, STATUS_CODE_522, STATUS_CODE_523, STATUS_CODE_524,
STATUS_CODE_525, STATUS_CODE_526, STATUS_CODE_527, STATUS_CODE_529,
[530] = STATUS_CODE_530,
[540] = STATUS_CODE_540,
[561] = STATUS_CODE_561,
Expand Down

0 comments on commit 5c4ce9b

Please sign in to comment.