Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(chart): add option to use other stratifier groups as datapoint #19

Merged
merged 1 commit into from
Oct 26, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions packages/demo/public/options.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,9 @@
"\"unbekannt\": kein Geburtsdatum oder Todesdatum bekannt."
]
},
"therapy_of_tumor": {
"aggregations": ["medicationStatements"]
},
"medicationStatements": {
"hintText": [
"Art der systemischen oder abwartenden Therapie (ADT Basisdatensatz Versionen 2014, 2021)"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@

<script lang="ts">
import { queryModified } from "../../stores/query";
console.log('asdf');
$: console.log($queryModified);
</script>

{#if $queryModified}
Expand Down
41 changes: 17 additions & 24 deletions packages/lib/src/components/results/ChartComponent.wc.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import Chart, { type ChartTypeRegistry } from "chart.js/auto";
import { onMount } from "svelte";
import {
getAggregatedPopulation,
getAggregatedPopulationForStratumCode,
getStratifierCodesForGroupCode,
responseStore,
Expand Down Expand Up @@ -163,16 +164,6 @@
},
};

/**
* searches the catalogue for the criteria names for the given catalogueGroupCode
* and sets them as chart labels
* DISCUSSION: needed? if so how do we implement this for bar charts?
*/
// $: {
// if(chartType === 'pie')
// initialChartData.data.labels = getCriteriaNamesFromKey($catalogue, catalogueGroupCode);
// }

/**
* @param chartLabels
* @returns an array of chart data sets from the response store
Expand Down Expand Up @@ -209,24 +200,28 @@
},
],
};
} else {
dataSet = chartLabels.map((label: string): number => {
const stratifierCode = label;
const stratifierCodeCount: number =
getAggregatedPopulationForStratumCode(
responseStore,
stratifierCode,
responseGroupCode
);
return stratifierCodeCount;
});
}
}


const combinedSubGroupData = combineSubGroups(
groupingDivider,
responseStore,
chartLabels
);


/**
* if aggregations are set, aggregate the data from other groups and adds them to the chart
* e.g. add aggregated number of medical statements to the chart for therapy of tumor
*/
if(options.aggregations){
options.aggregations.forEach((aggregation) => {
const aggregationCount = getAggregatedPopulation(responseStore, aggregation);
combinedSubGroupData.data.push(aggregationCount);
combinedSubGroupData.labels.push(aggregation);
});
}

return {
labels: combinedSubGroupData.labels,
data: [
Expand Down Expand Up @@ -390,7 +385,6 @@
* if a legend mapping is set, use the legend mapping
*/
chart.data.labels = options.legendMapping ? chartLabels.map(label => {
console.log(label, options )
return options.legendMapping[label]
}): chartLabels;

Expand Down Expand Up @@ -504,7 +498,6 @@

addItemToQuery(queryItem, $activeQueryGroupIndex);
};
// console.log(hintText);
</script>

<div part="chart-wrapper">
Expand Down
Loading