1
0
Fork 0
mirror of synced 2024-07-04 14:01:27 +12:00

Adding mode functionality to Donut

This commit is contained in:
cmack 2020-08-04 10:02:58 +01:00
parent ac9d5e660d
commit 31820c1bbf
3 changed files with 33 additions and 1 deletions

View file

@ -428,6 +428,11 @@ export default {
...all,
},
settings: [
{
label: "Table",
key: "model",
control: ModelSelect,
},
{
label: "Fix Highlight Slice",
key: "hasFixedHighlightedSlice",

View file

@ -259,6 +259,7 @@
"color": "string",
"height": "number",
"width": "number",
"model": "string",
"hasFixedHighlightedSlice": "bool",
"hasLastHoverSliceHighlighted": "bool",
"hasHoverAnimation": "bool",

View file

@ -15,6 +15,11 @@
let chartElement = null
let chartContainer = null
export let _bb
export let model
let store = _bb.store
export let customMouseOver = null
export let customMouseMove = null
export let customMouseOut = null
@ -22,7 +27,7 @@
export let orderingFunction = null
export let data = []
export let data = model ? $store[model] : []
export let color = "britecharts"
export let height = 200
export let width = 200
@ -41,6 +46,27 @@
export let radiusHoverOffset = 0
export let useLegend = true
async function fetchData() {
const FETCH_RECORDS_URL = `/api/views/all_${model}`
const response = await _bb.api.get(FETCH_RECORDS_URL)
if (response.status === 200) {
const json = await response.json()
store.update(state => {
state[model] = json
return state
})
} else {
throw new Error("Failed to fetch records.", response)
}
}
onMount(async () => {
await fetchData()
})
$: _data = model ? $store[model] : data
$: console.log("_data", _data)
onMount(() => {
if (chart) {
chart.emptyDataConfig({