fix bugs
This commit is contained in:
@@ -56,7 +56,7 @@ Chart.register({
|
||||
|
||||
ctx.font = '12px sans-serif';
|
||||
ctx.fillStyle = '#6b7280';
|
||||
ctx.fillText('Total cases', centerX, centerY + 12);
|
||||
ctx.fillText('Total Positive cases', centerX, centerY + 12);
|
||||
|
||||
ctx.restore();
|
||||
}
|
||||
@@ -377,19 +377,14 @@ export function buildDistributionChart(
|
||||
}
|
||||
export function getSubtypeColor(label, index = 0) {
|
||||
|
||||
const specialColors = {
|
||||
'A/H5N1': '#dc2626',
|
||||
'Influenza': '#b90c00'
|
||||
};
|
||||
|
||||
return specialColors[label]
|
||||
return SUBTYPE_COLORS[label]
|
||||
|| COLORS[index % COLORS.length];
|
||||
}
|
||||
|
||||
export const COLORS = [
|
||||
|
||||
'#ef4444', // blue
|
||||
'#10b981', // emerald
|
||||
'#ef4444',
|
||||
'#f59e0b', // amber
|
||||
'#ef4444', // red
|
||||
'#8b5cf6', // violet
|
||||
@@ -398,7 +393,6 @@ export const COLORS = [
|
||||
'#84cc16', // lime
|
||||
'#e11dba', // fuchsia
|
||||
'#f6f63b', // yellow
|
||||
|
||||
'#0ea5e9', // sky
|
||||
'#22c55e', // green
|
||||
'#a855f7', // purple
|
||||
@@ -428,6 +422,7 @@ export const SUBTYPE_COLORS = {
|
||||
'A/Unsubtypable': '#f455d7',
|
||||
'B/Yam': '#9333ea',
|
||||
'B/Vic': '#086037',
|
||||
'B/VIC': '#086037',
|
||||
'B/Unsubtypable': '#66ff00',
|
||||
'B/Victoria': '#9333ea',
|
||||
'H1N1pdm': '#f0d401',
|
||||
|
||||
@@ -197,10 +197,7 @@ function loadTrend(periodType, startYear, startWeek, endYear, endWeek) {
|
||||
grid: {
|
||||
display: false
|
||||
},
|
||||
title: {
|
||||
display: true,
|
||||
text: 'Surveillance'
|
||||
},
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -215,15 +212,16 @@ function loadInfluenzaSubtypeDistribution(periodType, startYear, startWeek, endY
|
||||
.then(res => res.json())
|
||||
.then(data => {
|
||||
|
||||
const displayData = data.map(item => ({
|
||||
...item,
|
||||
subtype: item.subtype === "B/VIC" ? "B/Vic" : item.subtype
|
||||
}));
|
||||
|
||||
data.forEach(row => {
|
||||
if (row.subtype === 'B/VIC') {
|
||||
row.subtype = 'B/Vic';
|
||||
}
|
||||
});
|
||||
|
||||
Charts.buildDistributionChart(
|
||||
'influenzaSubtypeDistribution',
|
||||
'bar',
|
||||
displayData,
|
||||
data,
|
||||
'subtype',
|
||||
'total',
|
||||
label => Charts.SUBTYPE_COLORS[label] || '#9ca3af'
|
||||
@@ -260,8 +258,6 @@ function loadCovidLineageFrequency(periodType, startYear, startWeek, endYear, en
|
||||
|
||||
const lineages = [...new Set(data.map(item => item.lineage))];
|
||||
|
||||
|
||||
|
||||
const datasets = lineages.map((lineage, index) => {
|
||||
|
||||
const lineageData = periods.map(period => {
|
||||
@@ -886,11 +882,6 @@ function getRadius(total) {
|
||||
return Math.max(4, Math.min(r * 2, 22));
|
||||
}
|
||||
|
||||
function getPositivityColor(subtype) {
|
||||
return Charts.SUBTYPE_COLORS[subtype] || "#9ca3af";
|
||||
}
|
||||
const getColorByPathogen = name =>
|
||||
Charts.SUBTYPE_COLORS[name] || '#9ca3af';
|
||||
|
||||
function addPositivityLegend() {
|
||||
|
||||
@@ -1202,9 +1193,7 @@ function loadProvinceMap(
|
||||
[lat, lng],
|
||||
{
|
||||
radius: getRadius(row.total),
|
||||
fillColor: getColorByPathogen(
|
||||
row.pathogen_name === 'B/VIC' ? 'B/Vic' : row.pathogen_name
|
||||
),
|
||||
fillColor: Charts.SUBTYPE_COLORS[row.pathogen_name === 'B/VIC' ? 'B/Vic' : row.pathogen_name] || '#9ca3af',
|
||||
fillOpacity: 0.85,
|
||||
stroke: false
|
||||
}
|
||||
|
||||
@@ -563,11 +563,11 @@ function renderProgramTrend(rows = []) {
|
||||
|
||||
}),
|
||||
|
||||
color: '#d21919'
|
||||
color: '#ef4444'
|
||||
},
|
||||
|
||||
{
|
||||
label: 'COVID-19 %',
|
||||
label: 'SARS-CoV-2 %',
|
||||
|
||||
data: labels.map(label => {
|
||||
|
||||
@@ -843,12 +843,10 @@ function renderAFITrend(
|
||||
|
|
||||
*/
|
||||
|
||||
const donutTotal =
|
||||
|
||||
totalCases.reduce(
|
||||
(a, b) => a + b,
|
||||
0
|
||||
);
|
||||
const donutTotal = rows.reduce(
|
||||
(sum, row) => sum + Number(row.total_positive || 0),
|
||||
0
|
||||
);
|
||||
|
||||
if (Charts.charts[canvasId]) {
|
||||
|
||||
@@ -946,6 +944,11 @@ function renderSentinel(rows = []) {
|
||||
}
|
||||
function renderSubtypeChart(rows = []) {
|
||||
|
||||
rows.forEach(row => {
|
||||
if (row.subtype === 'B/VIC') {
|
||||
row.subtype = 'B/Vic';
|
||||
}
|
||||
});
|
||||
|
||||
Charts.buildDistributionChart(
|
||||
'subtypeChart',
|
||||
|
||||
Reference in New Issue
Block a user