-
Notifications
You must be signed in to change notification settings - Fork 14.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[SIP-6] Migrate visualizations to new directory structure (part 3 - n…
…vd3) (#6006) * migrate nvd3 * update basicchartinput
- Loading branch information
1 parent
f9344f1
commit 5c2a788
Showing
7 changed files
with
128 additions
and
117 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,4 @@ | ||
import reactify from '../../utils/reactify'; | ||
import Component from './NVD3Vis'; | ||
|
||
export default reactify(Component); |
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,5 @@ | ||
import createAdaptor from '../../utils/createAdaptor'; | ||
import Component from './ReactNVD3'; | ||
import transformProps from './transformProps'; | ||
|
||
export default createAdaptor(Component, transformProps); |
112 changes: 112 additions & 0 deletions
112
superset/assets/src/visualizations/nvd3/transformProps.js
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,112 @@ | ||
import { isTruthy } from '../../utils/common'; | ||
import { formatLabel } from './utils'; | ||
|
||
export default function transformProps(basicChartInput) { | ||
const { | ||
annotationData, | ||
datasource, | ||
formData, | ||
onError, | ||
onAddFilter, | ||
payload, | ||
} = basicChartInput; | ||
|
||
const { | ||
annotationLayers, | ||
barStacked, | ||
bottomMargin, | ||
colorPicker, | ||
colorScheme, | ||
comparisonType, | ||
contribution, | ||
donut, | ||
entity, | ||
labelsOutside, | ||
leftMargin, | ||
lineInterpolation, | ||
maxBubbleSize, | ||
orderBars, | ||
pieLabelType, | ||
reduceXTicks, | ||
richTooltip, | ||
sendTimeRange, | ||
showBarValue, | ||
showBrush, | ||
showControls, | ||
showLabels, | ||
showLegend, | ||
showMarkers, | ||
size, | ||
stackedStyle, | ||
vizType, | ||
x, | ||
xAxisFormat, | ||
xAxisLabel, | ||
xAxisShowminmax, | ||
xLogScale, | ||
xTicksLayout, | ||
y, | ||
yAxisFormat, | ||
yAxis2Format, | ||
yAxisBounds, | ||
yAxisLabel, | ||
yAxisShowminmax, | ||
yLogScale, | ||
} = formData; | ||
|
||
const rawData = payload.data || []; | ||
const data = Array.isArray(rawData) | ||
? rawData.map(row => ({ | ||
...row, | ||
key: formatLabel(row.key, datasource.verbose_map), | ||
})) | ||
: rawData; | ||
|
||
return { | ||
data, | ||
annotationData, | ||
annotationLayers, | ||
areaStackedStyle: stackedStyle, | ||
baseColor: colorPicker, | ||
bottomMargin, | ||
colorScheme, | ||
comparisonType, | ||
contribution, | ||
entity, | ||
isBarStacked: barStacked, | ||
isDonut: donut, | ||
isPieLabelOutside: labelsOutside, | ||
leftMargin, | ||
lineInterpolation, | ||
maxBubbleSize: parseInt(maxBubbleSize, 10), | ||
onBrushEnd: isTruthy(sendTimeRange) ? ((timeRange) => { | ||
onAddFilter('__time_range', timeRange, false, true); | ||
}) : undefined, | ||
onError, | ||
orderBars, | ||
pieLabelType, | ||
reduceXTicks, | ||
showBarValue, | ||
showBrush, | ||
showControls, | ||
showLabels, | ||
showLegend, | ||
showMarkers, | ||
sizeField: size, | ||
useRichTooltip: richTooltip, | ||
vizType, | ||
xAxisFormat, | ||
xAxisLabel, | ||
xAxisShowMinMax: xAxisShowminmax, | ||
xField: x, | ||
xIsLogScale: xLogScale, | ||
xTicksLayout, | ||
yAxisFormat, | ||
yAxis2Format, | ||
yAxisBounds, | ||
yAxisLabel, | ||
yAxisShowMinMax: yAxisShowminmax, | ||
yField: y, | ||
yIsLogScale: yLogScale, | ||
}; | ||
} |