-
Notifications
You must be signed in to change notification settings - Fork 117
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
063abdb
commit 024e3a0
Showing
7 changed files
with
34 additions
and
55 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import { Document } from "yaml"; | ||
|
||
export function getChartYaml( | ||
vegaLite: string | undefined, | ||
resolver: string | undefined, | ||
resolverProperties: Record<string, any> | undefined, | ||
) { | ||
const doc = new Document(); | ||
doc.set("kind", "chart"); | ||
|
||
// TODO: more fields from resolverProperties | ||
if (resolver === "SQL") { | ||
doc.set("data", { sql: (resolverProperties?.sql as string) ?? "" }); | ||
} else if (resolver === "MetricsSQL") { | ||
doc.set("data", { metrics_sql: (resolverProperties?.sql as string) ?? "" }); | ||
} else if (resolver === "API") { | ||
doc.set("data", { api: (resolverProperties?.api as string) ?? "" }); | ||
} | ||
|
||
doc.set( | ||
"vega_lite", | ||
JSON.stringify(JSON.parse(vegaLite ?? "{}"), null, 2).replace(/^/gm, " "), | ||
); | ||
|
||
return doc.toString(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters