Browse Source

Tidyup

gh-pages
cmack 6 years ago
parent
commit
4352dd057d
  1. 20
      packages/standard-components/src/Chart/Donut.svelte

20
packages/standard-components/src/Chart/Donut.svelte

@ -36,8 +36,6 @@
export let width = 200 export let width = 200
export let margin = null export let margin = null
$: console.log("DATA", data)
export let centeredTextFunction = null export let centeredTextFunction = null
export let externalRadius = 25 export let externalRadius = 25
export let percentageFormat = null export let percentageFormat = null
@ -75,6 +73,11 @@
if (model) { if (model) {
await fetchData() await fetchData()
data = checkAndReformatData($store[model]) data = checkAndReformatData($store[model])
if (data.length === 0) {
console.error(
"Donut - please provide a valid name and value field for the chart"
)
}
} }
chart.emptyDataConfig({ chart.emptyDataConfig({
@ -107,13 +110,16 @@
let ignoreList = ["_id", "_rev", "id"] let ignoreList = ["_id", "_rev", "id"]
if (dataKey && data.every(d => d[dataKey])) { if (dataKey && data.every(d => d[dataKey])) {
return data.map(d => { return data.map(d => {
let obj = { ...d } let clonedRecord = { ...d }
let value = obj[dataKey] if (clonedRecord[formatKey]) {
delete clonedRecord[formatKey]
}
let value = clonedRecord[dataKey]
if (!ignoreList.includes(dataKey)) { if (!ignoreList.includes(dataKey)) {
delete obj[dataKey] delete clonedRecord[dataKey]
} }
obj[formatKey] = value clonedRecord[formatKey] = value
return obj return clonedRecord
}) })
} else { } else {
return data return data

Loading…
Cancel
Save