Giter VIP home page Giter VIP logo

Comments (2)

ZeRego avatar ZeRego commented on May 8, 2024

@TuringLovesDeathMetal @owlas any thoughts on this layout and text ? Tried to mimic what we have in the results section + all buttons disabled
Screenshot 2021-06-22 at 16 29 42

from lightdash.

owlas avatar owlas commented on May 8, 2024

@ZeRego that looks awesome!

I didn't mention before but the logic to determine whether the chart is valid is derived here:

export type ChartConfig = ChartConfigBase & ({
seriesLayout: ValidSeriesLayout,
plotData: {[col: string]: any}[],
} | {
seriesLayout: SeriesLayout,
plotData: undefined,
})
type ValidSeriesLayout = {
xDimension: string,
yMetrics: string[],
groupDimension: string | undefined,
}
type SeriesLayout = Partial<ValidSeriesLayout>

Where the ChartConfig.plotData can be undefined

Then there are two components that render depending on this hook:

SimpleChart.js

export const SimpleChart = ({chartType, chartConfig}: SimpleChartProps) => {
if(chartConfig.plotData === undefined)
return null

ChartConfigPanel.js

const Content = ({ chartConfig }: ContentProps) => {
return (
<div style={{display: 'flex', flexDirection: 'column', alignItems: 'flex-start', justifyContent: 'flex-start', width: '300px'}}>
<span><b>Metrics</b></span>
<Divider />
{chartConfig.metricOptions.map((metric, idx) => (
<div key={idx} style={{width: '100%'}}>
<Switch
checked={chartConfig.seriesLayout.yMetrics?.find(m => m===metric) !== undefined}
label={friendlyName(metric)}
alignIndicator={Alignment.RIGHT}
onChange={e => chartConfig.toggleYMetric(metric)}
disabled={(chartConfig.seriesLayout.yMetrics?.find(m => m===metric) === undefined) && chartConfig.seriesLayout.groupDimension !== undefined}
/>
</div>
))}
<span><b>Dimensions</b></span>
<Divider />
{chartConfig.dimensionOptions.map(dimension => (
<div style={{display: 'flex', flexDirection: 'row', alignItems: 'center', justifyContent: 'space-between', width: '100%'}}>
<span>{friendlyName(dimension)}</span>
<ButtonGroup minimal={true}>
<Button
outlined={true}
active={dimension === chartConfig.seriesLayout.xDimension}
onClick={() => chartConfig.setXDimension(dimension)}
>X-axis</Button>
<Button
outlined={true}
active={dimension === chartConfig.seriesLayout.groupDimension}
onClick={() => chartConfig.setGroupDimension(dimension === chartConfig.seriesLayout.groupDimension ? undefined : dimension)}
disabled={chartConfig.seriesLayout.yMetrics && chartConfig.seriesLayout.yMetrics.length > 1}
>Group</Button>
</ButtonGroup>
</div>
))}
</div>
)
}

from lightdash.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.