Skip to content

Commit

Permalink
Merge pull request #19 from samply/develop
Browse files Browse the repository at this point in the history
feat(chart): add option to use other stratifier groups as datapoint
  • Loading branch information
MatsJohansen87 authored Oct 26, 2023
2 parents 2607a94 + 884a708 commit a61fa82
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 26 deletions.
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

0 comments on commit a61fa82

Please sign in to comment.