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: add message for empty charts #164

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
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
29 changes: 27 additions & 2 deletions packages/lib/src/components/results/ChartComponent.wc.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,9 @@
/**
* initialize the chart
*/

let noDataAvailable: boolean = false;

let canvas!: HTMLCanvasElement;

let chart: Chart;
Expand Down Expand Up @@ -391,15 +394,23 @@
* @param responseStore - the response store
*/
const setChartData = (responseStore: ResponseStore): void => {
if (responseStore.size === 0) return;
if (responseStore.size === 0) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The logic is not correct, when the responseStore is empty it should be the "empty charts" look like the initial load. If the Store has results but not regarding this Diagramm then it should show the text

noDataAvailable = true;
return;
}

let isDataAvailable: boolean = false;

responseStore.forEach((value) => {
if (value.data !== null) isDataAvailable = true;
});

if (!isDataAvailable) return;
if (!isDataAvailable) {
noDataAvailable = true;
return;
}

noDataAvailable = false;

let chartLabels: string[] = [];

Expand Down Expand Up @@ -589,6 +600,11 @@
{#if options.hintText}
<InfoButtonComponent message={options.hintText} />
{/if}

{#if noDataAvailable}
<p>No Data Available</p>
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you make it less aggressive

{/if}

<canvas
part="chart-canvas"
bind:this={canvas}
Expand All @@ -597,3 +613,12 @@
/>
<slot />
</div>

<style>
p {
position: absolute;
top: 45%;
font-weight: bold;
left: 30%;
}
</style>
Loading