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:
Dawood Khan 2022-08-27 17:45:09 -04:00 committed by GitHub
parent f2733d8f94
commit 43c7e8a4a4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 22 additions and 2 deletions

View File

@ -0,0 +1,6 @@
<script lang="ts">
import type { FileData } from "../../File/types";
export let value: FileData;
</script>
<div class="truncate">{value}</div>

View File

@ -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
};

View File

@ -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"