|
145 | 145 | return Math.round(num || 0).toString().replace(/\B(?=(\d{3})+(?!\d))/g, ','); |
146 | 146 | } |
147 | 147 |
|
| 148 | + function roundToThousands(num) { |
| 149 | + if (num === null || num === undefined || isNaN(num)) return 0; |
| 150 | + return Math.round(num / 1000) * 1000; |
| 151 | + } |
| 152 | + |
148 | 153 | function loadWithFallback(loader, mainPath, fallbackPath, callback) { |
149 | 154 | loader(mainPath, function(err, data) { |
150 | 155 | if (!err && data) { |
|
283 | 288 | .style('font-size', '12px') |
284 | 289 | .style('font-weight', 'bold') |
285 | 290 | .text(function(d, i) { |
286 | | - return formatNumber(breaks[i]) + ' - ' + formatNumber(breaks[i + 1]); |
| 291 | + return formatNumber(roundToThousands(breaks[i])) + ' - ' + formatNumber(roundToThousands(breaks[i + 1])); |
287 | 292 | }); |
288 | 293 | } |
289 | 294 |
|
|
408 | 413 | if (!o || !d || o === d) return; |
409 | 414 |
|
410 | 415 | if (!odData[o]) odData[o] = {}; |
411 | | - odData[o][d] = {}; |
412 | 416 |
|
| 417 | + var rowValues = {}; |
413 | 418 | numericColumns.forEach(function(col) { |
414 | | - odData[o][d][col] = +row[col] || 0; |
| 419 | + rowValues[col] = Math.round(+row[col] || 0); |
415 | 420 | }); |
416 | 421 |
|
417 | | - // NOW countyNameByFips is defined |
418 | | - odData[o][d].origin_county = countyNameByFips[o] || firstDefined(row, ['origin_county', 'oName', 'Origin_County']) || o; |
419 | | - odData[o][d].destination_county = countyNameByFips[d] || firstDefined(row, ['destination_county', 'dName', 'Destination_County']) || d; |
420 | | - |
421 | | - console.log('OD Record:', o, '→', d, 'Value:', odData[o][d][selectedAttribute]); |
| 422 | + rowValues.origin_county = countyNameByFips[o] || firstDefined(row, ['origin_county', 'oName', 'Origin_County']) || o; |
| 423 | + rowValues.destination_county = countyNameByFips[d] || firstDefined(row, ['destination_county', 'dName', 'Destination_County']) || d; |
| 424 | + |
| 425 | + odData[o][d] = rowValues; |
422 | 426 | }); |
423 | 427 |
|
424 | 428 | var desireFeatures = getTopoFeatures(desirelinesTopo); |
|
0 commit comments