-
Notifications
You must be signed in to change notification settings - Fork 337
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
284413a
commit 994fe2f
Showing
22 changed files
with
787 additions
and
342 deletions.
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
import React, { useCallback } from "react"; | ||
import { observer } from 'mobx-react-lite'; | ||
import { PrimaryButton, Stack, Checkbox, Panel, PanelType, ComboBox, Label } from "office-ui-fabric-react"; | ||
import { Aggregator } from "../global"; | ||
import { useGlobalStore } from "../store"; | ||
const checkboxStyles = () => { | ||
return { | ||
root: { | ||
marginTop: "10px", | ||
}, | ||
}; | ||
}; | ||
|
||
// todo: import aggregators list from cube-core | ||
const aggregationList: Array<{ key: Aggregator; text: string }> = [ | ||
{ key: "sum", text: "Sum" }, | ||
{ key: "count", text: "Count" }, | ||
{ key: "mean", text: "Mean" }, | ||
]; | ||
|
||
const PreferencePanel: React.FC = () => { | ||
const { exploreStore } = useGlobalStore() | ||
const { visualConfig, showPreferencePannel } = exploreStore; | ||
|
||
const { aggregator, defaultAggregated, defaultStack } = visualConfig; | ||
|
||
const closeVisualPannel = useCallback(() => { | ||
exploreStore.setShowPreferencePannel(false); | ||
}, []) | ||
|
||
const onRenderFooterContent = () => ( | ||
<div> | ||
<PrimaryButton | ||
onClick={closeVisualPannel} | ||
> | ||
Save | ||
</PrimaryButton> | ||
</div> | ||
); | ||
|
||
return ( | ||
<Panel | ||
isOpen={showPreferencePannel} | ||
type={PanelType.smallFixedFar} | ||
onDismiss={closeVisualPannel} | ||
headerText="Preference" | ||
closeButtonAriaLabel="Close" | ||
onRenderFooterContent={onRenderFooterContent} | ||
> | ||
<Label>Preference</Label> | ||
<Stack verticalFill tokens={{ childrenGap: 50, padding: 6 }}> | ||
<ComboBox | ||
selectedKey={aggregator} | ||
label="Aggregator" | ||
allowFreeform={true} | ||
autoComplete="on" | ||
options={aggregationList} | ||
onChange={(e, option) => { | ||
if (option) { | ||
exploreStore.setVisualConig(config => { | ||
config.aggregator = option.key as Aggregator; | ||
}) | ||
} | ||
}} | ||
/> | ||
<Checkbox | ||
styles={checkboxStyles} | ||
label="measurement aggregation" | ||
checked={defaultAggregated} | ||
onChange={(e, isChecked) => { | ||
exploreStore.setVisualConig(config => { | ||
visualConfig.defaultAggregated = isChecked || false; | ||
}) | ||
}} | ||
/> | ||
<Checkbox | ||
styles={checkboxStyles} | ||
label="measurement stack" | ||
checked={defaultStack} | ||
onChange={(e, isChecked) => { | ||
exploreStore.setVisualConig(config => { | ||
visualConfig.defaultStack = isChecked || false; | ||
}) | ||
}} | ||
/> | ||
</Stack> | ||
</Panel> | ||
); | ||
}; | ||
|
||
export default observer(PreferencePanel); |
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
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
105 changes: 56 additions & 49 deletions
105
packages/frontend/src/pages/lts/association/assCharts.tsx
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,67 +1,74 @@ | ||
import React from "react"; | ||
// import VisDescription from "../../../plugins/visSummary/description"; | ||
// import useDigDimension, { DigDimensionProps } from "./digDimension"; | ||
import BaseChart from "../../../visBuilder/vegaBase"; | ||
import { FieldSummary, Subspace } from "../../../service"; | ||
// import { IconButton, Stack } from "office-ui-fabric-react"; | ||
import { FieldSummary } from "../../../service"; | ||
import { IInsightSpace, Specification } from "visual-insights"; | ||
import { PreferencePanelConfig } from "../../../components/preference"; | ||
import { IRow } from "../../../interfaces"; | ||
|
||
import { IconButton } from "office-ui-fabric-react"; | ||
import intl from 'react-intl-universal'; | ||
export interface IVizSpace extends IInsightSpace { | ||
schema: Specification; | ||
dataView: IRow[] | ||
} | ||
|
||
interface AssociationProps { | ||
visualConfig: PreferencePanelConfig; | ||
// subspaceList: Subspace[]; | ||
vizList: IVizSpace[]; | ||
fieldScores: FieldSummary[]; | ||
dataSource: IRow[]; | ||
onSelectView: (index: number) => void | ||
visualConfig: PreferencePanelConfig; | ||
// subspaceList: Subspace[]; | ||
vizList: IVizSpace[]; | ||
fieldScores: FieldSummary[]; | ||
dataSource: IRow[]; | ||
onSelectView: (viz: IVizSpace) => void | ||
} | ||
const AssociationCharts: React.FC<AssociationProps> = props => { | ||
const { vizList, onSelectView, visualConfig, fieldScores, dataSource } = props; | ||
// const { dataSource, fieldScores } = digDimensionProps; | ||
// const relatedCharts = useDigDimension(digDimensionProps); | ||
const fieldFeatures = fieldScores.map(f => ({ | ||
name: f.fieldName, | ||
type: f.type | ||
})); | ||
//className="ms-Grid" | ||
return ( | ||
<div style={{ border: "solid 1px #bfbfbf", marginTop: '2em' }}> | ||
const { vizList, onSelectView, visualConfig, fieldScores, dataSource } = props; | ||
// const { dataSource, fieldScores } = digDimensionProps; | ||
// const relatedCharts = useDigDimension(digDimensionProps); | ||
const fieldFeatures = fieldScores.map(f => ({ | ||
name: f.fieldName, | ||
type: f.type | ||
})); | ||
//className="ms-Grid" | ||
return ( | ||
<div style={{ border: "solid 1px #bfbfbf", marginTop: '2em', backgroundColor: '#e7e7e7' }}> | ||
|
||
<div style={{ display: 'flex', flexWrap: 'wrap', overflow: 'auto' }}> | ||
{vizList.map((view, i) => { | ||
return ( | ||
<div key={`associate-row-${i}`} | ||
// className="ms-Grid-row" | ||
dir="ltr" | ||
style={{ | ||
// border: "solid 1px #bfbfbf", | ||
margin: "1em", | ||
padding: "1em" | ||
}} | ||
> | ||
<BaseChart | ||
fixedWidth={false} | ||
aggregator={visualConfig.aggregator} | ||
defaultAggregated={view.schema.geomType && view.schema.geomType.includes("point") ? false : true} | ||
defaultStack={visualConfig.defaultStack} | ||
dimensions={view.dimensions} | ||
measures={view.measures} | ||
dataSource={dataSource} | ||
schema={view.schema} | ||
fieldFeatures={fieldFeatures} | ||
/> | ||
<div style={{ display: 'flex', flexWrap: 'wrap', overflow: 'auto' }}> | ||
{vizList.map((view, i) => { | ||
return ( | ||
<div key={`associate-row-${i}`} | ||
// className="ms-Grid-row" | ||
dir="ltr" | ||
style={{ | ||
// border: "solid 1px #bfbfbf", | ||
backgroundColor:'#fff', | ||
margin: "1em", | ||
padding: "1em" | ||
}} | ||
> | ||
<BaseChart | ||
fixedWidth={false} | ||
aggregator={visualConfig.aggregator} | ||
defaultAggregated={view.schema.geomType && view.schema.geomType.includes("point") ? false : true} | ||
defaultStack={visualConfig.defaultStack} | ||
dimensions={view.dimensions} | ||
measures={view.measures} | ||
dataSource={dataSource} | ||
schema={view.schema} | ||
fieldFeatures={fieldFeatures} | ||
/> | ||
<IconButton | ||
iconProps={{ iconName: 'Lightbulb' }} | ||
title={intl.get('explore.digIn')} | ||
ariaLabel={intl.get('explore.digIn')} | ||
onClick={() => { | ||
onSelectView(view); | ||
}} | ||
/> | ||
</div> | ||
); | ||
})} | ||
</div> | ||
); | ||
})} | ||
</div> | ||
</div> | ||
); | ||
</div> | ||
); | ||
}; | ||
|
||
export default AssociationCharts; |
Oops, something went wrong.