in src/app/stores/app_store.ts [1457:1606]
public updatePlotSegments() {
// Get plot segments to update with new data
const plotSegments: Specification.PlotSegment[] = this.chart.elements.filter(
(element) => Prototypes.isType(element.classID, "plot-segment")
) as Specification.PlotSegment[];
// eslint-disable-next-line
plotSegments.forEach((plot: Specification.PlotSegment) => {
const table = this.dataset.tables.find(
(table) => table.name === plot.table
);
// xData
const xDataProperty: Specification.Types.AxisDataBinding = (plot.properties as Region2DProperties)
.xData;
if (xDataProperty && xDataProperty.expression) {
const xData = new DragData.DataExpression(
table,
xDataProperty.expression,
xDataProperty.valueType,
{
kind:
xDataProperty.type === "numerical" &&
xDataProperty.numericalMode === "temporal"
? DataKind.Temporal
: xDataProperty.dataKind
? xDataProperty.dataKind
: this.getDataKindByType(xDataProperty.type),
orderMode: xDataProperty.orderMode
? xDataProperty.orderMode
: xDataProperty.valueType === "string" ||
xDataProperty.valueType === "number"
? OrderMode.order
: null,
order:
xDataProperty.order != undefined
? xDataProperty.order
: xDataProperty.orderByCategories
? xDataProperty.orderByCategories
: null,
orderByExpression:
xDataProperty.orderByExpression !== undefined
? xDataProperty.orderByExpression
: null,
},
xDataProperty.rawExpression as string
);
this.bindDataToAxis({
property: PlotSegmentAxisPropertyNames.xData,
dataExpression: xData,
object: plot,
appendToProperty: null,
type: xDataProperty.type, // TODO get type for column, from current dataset
numericalMode: xDataProperty.numericalMode,
autoDomainMax: xDataProperty.autoDomainMax,
autoDomainMin: xDataProperty.autoDomainMin,
domainMin: xDataProperty.domainMin,
domainMax: xDataProperty.domainMax,
defineCategories: true,
});
}
// yData
const yDataProperty: Specification.Types.AxisDataBinding = (plot.properties as Region2DProperties)
.yData;
if (yDataProperty && yDataProperty.expression) {
const yData = new DragData.DataExpression(
table,
yDataProperty.expression,
yDataProperty.valueType,
{
kind:
yDataProperty.type === "numerical" &&
yDataProperty.numericalMode === "temporal"
? DataKind.Temporal
: yDataProperty.dataKind
? yDataProperty.dataKind
: this.getDataKindByType(yDataProperty.type),
orderMode: yDataProperty.orderMode
? yDataProperty.orderMode
: yDataProperty.valueType === "string"
? OrderMode.order
: null,
order:
yDataProperty.order !== undefined ? yDataProperty.order : null,
},
yDataProperty.rawExpression as string
);
this.bindDataToAxis({
property: PlotSegmentAxisPropertyNames.yData,
dataExpression: yData,
object: plot,
appendToProperty: null,
type: yDataProperty.type, // TODO get type for column, from current dataset
numericalMode: yDataProperty.numericalMode,
autoDomainMax: yDataProperty.autoDomainMax,
autoDomainMin: yDataProperty.autoDomainMin,
domainMin: yDataProperty.domainMin,
domainMax: yDataProperty.domainMax,
defineCategories: true,
});
}
const axisProperty: Specification.Types.AxisDataBinding = (plot.properties as LineGuideProperties)
.axis;
if (axisProperty && axisProperty.expression) {
const axisData = new DragData.DataExpression(
table,
axisProperty.expression !== undefined
? axisProperty.expression
: null,
axisProperty.valueType !== undefined ? axisProperty.valueType : null,
{
kind:
axisProperty.type === "numerical" &&
axisProperty.numericalMode === "temporal"
? DataKind.Temporal
: axisProperty.dataKind
? axisProperty.dataKind
: this.getDataKindByType(axisProperty.type),
orderMode: axisProperty.orderMode
? axisProperty.orderMode
: axisProperty.valueType === "string"
? OrderMode.order
: null,
order: axisProperty.order !== undefined ? axisProperty.order : null,
},
axisProperty.rawExpression as string
);
this.bindDataToAxis({
property: PlotSegmentAxisPropertyNames.axis,
dataExpression: axisData,
object: plot,
appendToProperty: null,
type: axisProperty.type, // TODO get type for column, from current dataset
numericalMode: axisProperty.numericalMode
? axisProperty.numericalMode
: null,
autoDomainMax: axisProperty.autoDomainMax,
autoDomainMin: axisProperty.autoDomainMin,
domainMin: axisProperty.domainMin,
domainMax: axisProperty.domainMax,
defineCategories: true,
});
}
});
}