Skip to content

Commit

Permalink
feat: wip
Browse files Browse the repository at this point in the history
  • Loading branch information
andresgutgon committed Mar 18, 2024
1 parent 0ce9cf2 commit b4f0fbd
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
7 changes: 5 additions & 2 deletions packages/client/core/src/theme/ui/chart/config/pie/index.ts
@@ -1,7 +1,7 @@
import { EChartsOption } from 'echarts'
import { isNaN } from 'lodash-es'
import { DBSource, DBSourceRow, Dataset } from '../../types'
import { getDataset } from '../common/getDataset'
import { Sort, getDataset } from '../common/getDataset'
import setLegend from '../common/setLegend'
import { COLORS, FONT } from '../common/designTokens'

Expand Down Expand Up @@ -37,12 +37,14 @@ const CONIFG_DEFAULTS: ConfigProps = {

export type PieChartProps = {
dataset: Dataset
sort?: Sort
displayName?: string
animation?: boolean
config?: ConfigProps
}
export default function generatePieConfig({
dataset,
sort,
displayName,
animation = true,
config: {
Expand All @@ -53,7 +55,7 @@ export default function generatePieConfig({
showHole = false,
} = CONIFG_DEFAULTS,
}: PieChartProps): EChartsOption {
const { datasets } = getDataset({ dataset })
const { datasets, datasetIndex } = getDataset({ dataset, sort })
const legend = setLegend({ show: showLegend })
const totalValues = sumValues(dataset.source, DEFAULT_VALUE_INDEX)
return {
Expand Down Expand Up @@ -119,6 +121,7 @@ export default function generatePieConfig({
value: DEFAULT_VALUE_INDEX,
itemName: DEFAULT_LABEL_INDEX,
},
datasetIndex
},
],
aria: { enabled: showDecal, decal: { show: showDecal } },
Expand Down
Expand Up @@ -16,6 +16,7 @@
type $$Props = PieChartProps
export let data: $$Props['data'] = null
export let sort: $$Props['sort'] = undefined
export let isLoading: $$Props['isLoading'] = false
export let error: $$Props['error'] = null
Expand Down Expand Up @@ -44,7 +45,13 @@
>
<Echart
height={contentHeight}
options={generatePieConfig({ dataset, displayName, animation, config })}
options={generatePieConfig({
dataset,
sort,
displayName,
animation,
config,
})}
{width}
{locale}
/>
Expand Down

0 comments on commit b4f0fbd

Please sign in to comment.