in powerbi-visual-builder/src_extension/builder.ts [204:329]
private mapPropertyToType(property: PowerBIProperty) {
let type: any = { text: true };
switch (property.type) {
case "number": {
type = { numeric: true };
switch (property.target.attribute) {
case "fontSize": {
type = { formatting: { fontSize: true } };
break;
}
case "fontFamily": {
type = { formatting: { fontFamily: true } };
break;
}
}
break;
}
case "font-family": {
type = { formatting: { fontFamily: true } };
break;
}
case "color": {
type = { fill: { solid: { color: true } } };
break;
}
case "boolean": {
type = { bool: true };
break;
}
case "enum": {
switch (property.target.attribute) {
case "symbol": {
type = {
enumeration: symbolTypes.map(sym => {
return {
displayName: sym,
value: sym
};
})
};
break;
}
}
switch (property.target.property) {
case "alignY":
case "alignX": {
type = {
enumeration: ["end", "middle", "start"].map(sym => {
return {
displayName: sym[0].toLocaleUpperCase() + sym.slice(1),
value: sym
};
})
};
break;
}
default: {
type = { text: true };
}
}
if (
typeof property.target.property === "object" &&
(property.target.property.property === "xData" ||
property.target.property.property === "yData" ||
property.target.property.property === "axis") &&
property.target.property.field === "categories"
) {
type = {
enumeration: ["ascending", "descending"].map(enumeration => {
return {
displayName:
enumeration[0].toLocaleUpperCase() + enumeration.slice(1),
value: enumeration
};
})
};
}
break;
}
case "object": {
if (
property.target.property &&
(property.target.property as any).property === "sublayout"
) {
if (
property.target.property &&
(property.target.property as any).field === "order"
) {
const object = Charticulator.Core.Prototypes.findObjectById(
this.template.specification,
property.objectID
);
const isPlotSegment =
Charticulator.Core.Prototypes.isType(
object.classID,
"plot-segment"
) ||
Charticulator.Core.Prototypes.isType(
object.classID,
"mark.data-axis"
);
if (isPlotSegment) {
const table = (object as any).table; // TODO fix to Charticulator.Core.Prototypes.PlotSegments
const columns = this.template.tables.find(t => t.name === table)
.columns;
type = {
enumeration: columns.map(col => {
return {
displayName: col.name,
value: `first(${col.name})`
};
})
};
break;
}
}
}
}
default: {
type = { text: true };
}
}
return type;
}