Merge pull request #178 from pjsier/fix/layer-function-type

Assigning default function type from spec
This commit is contained in:
Orange Mug 2017-10-18 17:31:13 +01:00 committed by GitHub
commit ddb3bcde43

View file

@ -89,6 +89,16 @@ export default class FunctionSpecProperty extends React.Component {
this.props.onChange(this.props.fieldName, zoomFunc)
}
getFieldFunctionType(fieldSpec) {
if (fieldSpec.function === "interpolated") {
return "exponential"
}
if (fieldSpec.type === "number") {
return "interval"
}
return "categorical"
}
getDataFunctionTypes(functionType) {
if (functionType === "interpolated") {
return ["categorical", "interval", "exponential"]
@ -131,6 +141,9 @@ export default class FunctionSpecProperty extends React.Component {
}
renderDataProperty() {
if (typeof this.props.value.type === "undefined") {
this.props.value.type = this.getFieldFunctionType(this.props.fieldSpec)
}
const dataFields = this.props.value.stops.map((stop, idx) => {
const zoomLevel = stop[0].zoom
const dataLevel = stop[0].value