Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
xValue: TableSuggestionColumn;
splitBy: TableSuggestionColumn | undefined;
layerId: string;
changeType: TableChangeType;
}) {
const newLayer = {
...(getExistingLayer(currentState, layerId) || {}),
layerId,
seriesType,
xAccessor: xValue.columnId,
splitAccessor: splitBy ? splitBy.columnId : generateId(),
accessors: yValues.map(col => col.columnId),
};
const state: State = {
legend: currentState ? currentState.legend : { isVisible: true, position: Position.Right },
preferredSeriesType: seriesType,
layers: [
...(currentState ? currentState.layers.filter(layer => layer.layerId !== layerId) : []),
newLayer,
],
};
return {
title,
score: getScore(yValues, splitBy, changeType),
// don't advertise chart of same type but with less data
hide: currentState && changeType === 'reduced',
state,
previewIcon: getIconForSeries(seriesType),
};
}
initialize(frame, state) {
return (
state || {
title: 'Empty XY Chart',
legend: { isVisible: true, position: Position.Right },
preferredSeriesType: defaultSeriesType,
layers: [
{
layerId: frame.addNewLayer(),
accessors: [generateId()],
position: Position.Top,
seriesType: defaultSeriesType,
showGridlines: false,
splitAccessor: generateId(),
xAccessor: generateId(),
},
],
}
);
},