clear timeseries fix (#2487)

This commit is contained in:
Dawood Khan 2022-10-18 16:09:33 -04:00 committed by GitHub
parent d7c96e1ad8
commit 8a34a799d6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 25 additions and 9 deletions

View File

@ -68,6 +68,7 @@ gr.Interface(iteration,
## Bug Fixes:
* Add loading status tracker UI to HTML and Markdown components. [@pngwn](https://github.com/pngwn) in [PR 2474](https://github.com/gradio-app/gradio/pull/2474)
* Fixed videos being mirrored in the front-end if source is not webcam by [@freddyaboulton](https://github.com/freddyaboulton) in [PR 2475](https://github.com/gradio-app/gradio/pull/2475)
* Add clear button for timeseries component [@dawoodkhan82](https://github.com/dawoodkhan82) in [PR 2487](https://github.com/gradio-app/gradio/pull/2487)
* Removes special characters from temporary filenames so that the files can be served by components [@abidlabs](https://github.com/abidlabs) in [PR 2480](https://github.com/gradio-app/gradio/pull/2480)
## Documentation Changes:
@ -83,6 +84,7 @@ No changes to highlight.
* Enable running events to be cancelled from other events by [@freddyaboulton](https://github.com/freddyaboulton) in [PR 2433](https://github.com/gradio-app/gradio/pull/2433)
* Small fix for version check before reuploading demos by [@aliabd](https://github.com/aliabd) in [PR 2469](https://github.com/gradio-app/gradio/pull/2469)
* Add loading status tracker UI to HTML and Markdown components. [@pngwn](https://github.com/pngwn) in [PR 2400](https://github.com/gradio-app/gradio/pull/2474)
* Add clear button for timeseries component [@dawoodkhan82](https://github.com/dawoodkhan82) in [PR 2487](https://github.com/gradio-app/gradio/pull/2487)
## Contributors Shoutout:
No changes to highlight.

View File

@ -1,6 +1,6 @@
<script lang="ts">
import { createEventDispatcher } from "svelte";
import { Upload } from "@gradio/upload";
import { Upload, ModifyUpload } from "@gradio/upload";
import type { FileData } from "@gradio/upload";
import { Block, BlockLabel } from "@gradio/atoms";
import { Chart } from "@gradio/chart";
@ -17,7 +17,10 @@
);
}
const dispatch = createEventDispatcher<{ change: undefined }>();
const dispatch = createEventDispatcher<{
change: undefined;
clear: undefined;
}>();
interface StaticData {
data: Array<Array<number>>;
@ -119,6 +122,12 @@
return v;
}
function handle_clear({ detail }: CustomEvent<FileData | null>) {
value = null;
dispatch("change");
dispatch("clear");
}
$: _value = value == null ? null : _value;
$: static_data =
mode === "static" && value && format_value(value as StaticData);
@ -145,13 +154,18 @@
</div>
{/if}
{:else if _value}
<Chart
value={_value}
{y}
{x}
on:process={({ detail: { x, y } }) => (value = make_dict(x, y))}
{colors}
/>
<div
class="input-model w-full h-60 flex justify-center items-center bg-gray-200 dark:bg-gray-600 relative"
>
<ModifyUpload on:clear={handle_clear} />
<Chart
value={_value}
{y}
{x}
on:process={({ detail: { x, y } }) => (value = make_dict(x, y))}
{colors}
/>
</div>
{:else if value === undefined || value === null}
<div class="h-full min-h-[8rem]">
<Upload