mirror of
https://github.com/gradio-app/gradio.git
synced 2024-11-27 01:40:20 +08:00
Fix TimeSeries examples not properly displayed in UI (#2064)
* fix * fix * format * fixes * type fixes * pr fixes Co-authored-by: Abubakar Abid <abubakar@huggingface.co>
This commit is contained in:
parent
f2733d8f94
commit
43c7e8a4a4
@ -0,0 +1,6 @@
|
||||
<script lang="ts">
|
||||
import type { FileData } from "../../File/types";
|
||||
export let value: FileData;
|
||||
</script>
|
||||
|
||||
<div class="truncate">{value}</div>
|
@ -12,6 +12,7 @@ import ExampleFile from "./ExampleComponents/File.svelte";
|
||||
import ExampleDataframe from "./ExampleComponents/Dataframe.svelte";
|
||||
import ExampleModel3D from "./ExampleComponents/Model3D.svelte";
|
||||
import ExampleColorPicker from "./ExampleComponents/ColorPicker.svelte";
|
||||
import ExampleTimeSeries from "./ExampleComponents/TimeSeries.svelte";
|
||||
|
||||
export const component_map = {
|
||||
dropdown: ExampleDropdown,
|
||||
@ -27,5 +28,6 @@ export const component_map = {
|
||||
file: ExampleFile,
|
||||
dataframe: ExampleDataframe,
|
||||
model3d: ExampleModel3D,
|
||||
colorpicker: ExampleColorPicker
|
||||
colorpicker: ExampleColorPicker,
|
||||
timeseries: ExampleTimeSeries
|
||||
};
|
||||
|
@ -70,10 +70,22 @@
|
||||
reader.readAsText(blob);
|
||||
}
|
||||
|
||||
function dict_to_string(dict: Data) {
|
||||
if (dict.headers) _value = dict.headers.join(",");
|
||||
const data = dict.data as Array<Array<number>>;
|
||||
data.forEach((x: Array<unknown>) => {
|
||||
_value = _value + "\n";
|
||||
_value = _value + x.join(",");
|
||||
});
|
||||
}
|
||||
|
||||
$: {
|
||||
if (value && value.data && typeof value.data === "string") {
|
||||
if (!value) _value = null;
|
||||
else blob_to_string(data_uri_to_blob(value.data));
|
||||
} else if (value && value.data && typeof value.data != "string") {
|
||||
if (!value) _value = null;
|
||||
dict_to_string(value);
|
||||
}
|
||||
}
|
||||
|
||||
@ -144,7 +156,7 @@
|
||||
on:process={({ detail: { x, y } }) => (value = make_dict(x, y))}
|
||||
{colors}
|
||||
/>
|
||||
{:else if value === undefined}
|
||||
{:else if value === undefined || value === null}
|
||||
<div class="h-full min-h-[8rem]">
|
||||
<Upload
|
||||
filetype="text/csv"
|
||||
|
Loading…
Reference in New Issue
Block a user