-
Notifications
You must be signed in to change notification settings - Fork 37
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
Chart experiments #316
Draft
dantownsend
wants to merge
17
commits into
master
Choose a base branch
from
charts-experiments
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Chart experiments #316
Changes from all commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
c3c19a2
add charts support
sinisaos 9ec5ccc
Resolved merge conflict
sinisaos cafb5c4
fix Playwright tests
sinisaos 9ff7282
fix charts in dark mode
sinisaos bc19e7c
Merge branch 'piccolo-orm:master' into charts_support
sinisaos 6d8909a
Merge branch 'piccolo-orm:master' into charts_support
sinisaos da9fe50
add suggested changes
sinisaos 976f55b
make chart data dynamic
dantownsend a2196f4
`data` -> `data_source`
dantownsend 51bc8f9
update unit tests
dantownsend c21bf11
fix codeql warning
dantownsend e50363f
mention chart support in README and docs homepage
dantownsend 8adad83
tweak docs
dantownsend e69a3d2
return tuple in example app
dantownsend 5ba77ca
data sources can accept pydantic models
dantownsend 3b5cd41
fix tests
dantownsend 96fde3d
hooked up form
dantownsend File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Large diffs are not rendered by default.
Oops, something went wrong.
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,114 @@ | ||
<template> | ||
<div v-if="chartConfig"> | ||
<h3>{{ chartConfig.title }}</h3> | ||
<pie-chart | ||
width="650px" | ||
height="450px" | ||
:download="{ background: '#ffffff' }" | ||
v-if="chartConfig.chart_type == 'Pie'" | ||
:data="chartData" | ||
></pie-chart> | ||
<line-chart | ||
width="650px" | ||
height="450px" | ||
:download="{ background: '#ffffff' }" | ||
v-else-if="chartConfig.chart_type == 'Line'" | ||
:data="chartData" | ||
></line-chart> | ||
<column-chart | ||
width="650px" | ||
height="450px" | ||
:download="{ background: '#ffffff' }" | ||
v-else-if="chartConfig.chart_type == 'Column'" | ||
:data="chartData" | ||
></column-chart> | ||
<bar-chart | ||
width="650px" | ||
height="450px" | ||
:download="{ background: '#ffffff' }" | ||
v-else-if="chartConfig.chart_type == 'Bar'" | ||
:data="chartData" | ||
></bar-chart> | ||
<area-chart | ||
width="650px" | ||
height="450px" | ||
:download="{ background: '#ffffff' }" | ||
v-else-if="chartConfig.chart_type == 'Area'" | ||
:data="chartData" | ||
></area-chart> | ||
|
||
<form @submit.prevent="handleSubmit($event)" v-if="chartSchema"> | ||
<NewForm :schema="chartSchema"></NewForm> | ||
<button>Apply</button> | ||
</form> | ||
</div> | ||
</template> | ||
|
||
<script lang="ts"> | ||
import Vue from "vue" | ||
import NewForm from "./NewForm.vue" | ||
import { convertFormValue } from "@/utils" | ||
|
||
export default Vue.extend({ | ||
data() { | ||
return { | ||
chartData: [], | ||
chartConfig: null, | ||
chartSchema: null, | ||
chartSlug: null | ||
} | ||
}, | ||
components: { NewForm }, | ||
methods: { | ||
async handleSubmit(event) { | ||
const form = new FormData(event.target) | ||
|
||
const json = {} | ||
for (const i of form.entries()) { | ||
const key = i[0] | ||
let value = i[1] | ||
|
||
json[key] = convertFormValue({ | ||
key, | ||
value, | ||
schema: this.chartSchema | ||
}) | ||
} | ||
|
||
this.chartData = ( | ||
await this.$store.dispatch("fetchChartData", { | ||
chartSlug: this.chartSlug, | ||
data: json | ||
}) | ||
).data | ||
} | ||
}, | ||
async mounted() { | ||
this.chartSlug = this.$router.currentRoute.params.chartSlug | ||
|
||
this.chartData = ( | ||
await this.$store.dispatch("fetchChartData", { | ||
chartSlug: this.chartSlug, | ||
data: {} | ||
}) | ||
).data | ||
|
||
this.chartConfig = ( | ||
await this.$store.dispatch("fetchChartConfig", this.chartSlug) | ||
).data | ||
|
||
if (this.chartConfig.has_form) { | ||
this.chartSchema = ( | ||
await this.$store.dispatch("fetchChartSchema", this.chartSlug) | ||
).data | ||
} | ||
} | ||
}) | ||
</script> | ||
|
||
<style scoped lang="less"> | ||
h3 { | ||
text-transform: capitalize; | ||
text-align: center; | ||
} | ||
</style> |
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,31 @@ | ||
<template> | ||
<ul> | ||
<li v-bind:key="chartConfig.title" v-for="chartConfig in chartConfigs"> | ||
<router-link | ||
:to="{ | ||
name: 'chart', | ||
params: { chartSlug: chartConfig.slug } | ||
}" | ||
class="subtle" | ||
> | ||
<font-awesome-icon icon="level-up-alt" class="rotated90" /> | ||
<span>{{ chartConfig.title }}</span> | ||
</router-link> | ||
</li> | ||
</ul> | ||
</template> | ||
|
||
<script lang="ts"> | ||
import Vue from "vue" | ||
|
||
export default Vue.extend({ | ||
computed: { | ||
chartConfigs() { | ||
return this.$store.state.chartConfigs | ||
} | ||
}, | ||
async mounted() { | ||
await this.$store.dispatch("fetchChartConfigs") | ||
} | ||
}) | ||
</script> |
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 |
---|---|---|
@@ -1,5 +1,5 @@ | ||
<template> | ||
<div> | ||
<div class="sidebar_wrapper"> | ||
<ul class="table_list"> | ||
<TableNavItem | ||
v-bind:key="tableName" | ||
|
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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a way to change Chart.js colors in dark mode, but unfortunately it doesn't work without refreshing the page. I'm sorry I didn't check before posting the suggested change.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No worries, it's still useful - there might be a way to reload the chart without reloading the entire page.