diff --git a/docs/unit-configuration.md b/docs/unit-configuration.md index 76cfcea825..e020e5364f 100644 --- a/docs/unit-configuration.md +++ b/docs/unit-configuration.md @@ -157,13 +157,13 @@ Not updated to common toolbar framework and does not support toolbar configurati #### Graph -- `autoAssignAttributes`: boolean, default true -- `connectPointsByDefault`: boolean, default true -- `defaultSeriesLegend`: boolean, default true +- `autoAssignAttributes`: boolean, default true. When true, when a dataset is connected to the graph, its first two columns will be immediately assigned to the "x" and "y" axes of the graph. +- `connectPointsByDefault`: boolean, default true. When true connecting lines between data points are drawn. - `defaultAxisLabels`: { "bottom": "x", "left": "y" }, default none -- `disableAttributeDnD`: boolean, default true -- `emptyPlotIsNumeric`: boolean, default true -- `scalePlotOnValueChange`: boolean, default true +- `defaultSeriesLegend`: boolean, default true. When true, the graph can connect to and display multiple datasets, and includes a legend area which allows adding, modifying, and removing these layers. +- `disableAttributeDnD`: boolean, default true. When true, you cannot drop attributes onto the axes to change the graph. "false" setting not currently tested. +- `emptyPlotIsNumeric`: boolean, default true. When true graph defaults to numeric axes. "false" setting not currently tested. +- `scalePlotOnValueChange`: boolean, default true. When true, adding/deleting/modifying value of any data causes the graph to be rescaled to fit the data. Uses the common toolbar framework. Default toolbar buttons: diff --git a/src/hooks/use-consumer-tile-linking.ts b/src/hooks/use-consumer-tile-linking.ts index bf6bca4cb4..a8d4300862 100644 --- a/src/hooks/use-consumer-tile-linking.ts +++ b/src/hooks/use-consumer-tile-linking.ts @@ -12,6 +12,7 @@ import { SharedModelUnion } from "../models/shared/shared-model-manager"; import { SharedModelType } from "../models/shared/shared-model"; import { logSharedModelDocEvent } from "../models/document/log-shared-model-document-event"; import { LogEventName } from "../lib/logger-types"; +import { useAppConfig } from "./use-stores"; interface IProps { // TODO: This should be replaced with a generic disabled @@ -56,6 +57,7 @@ interface IProps { export const useConsumerTileLinking = ({ model, shareType, hasLinkableRows, readOnly, tileType, onLinkTile, onUnlinkTile, onCreateTile }: IProps) => { + const appConfig = useAppConfig(); // In the future we might need to limit this search to only tiles that are consumers for 'shareType'. // At the moment we have no cases where it matters. const { consumers: linkableTilesAllTypes } = useLinkableTiles({ model }); @@ -89,7 +91,8 @@ export const useConsumerTileLinking = ({ // Don't remove old links before adding the new one, since some models (eg, table) take action // if they see they have no linked data. let dataSetsToRemove = [] as SharedModelType[]; - if (shareType === SharedDataSet && !getTileContentInfo(consumerTile.type)?.consumesMultipleDataSets) { + const allowsMultiple = getTileContentInfo(consumerTile.type)?.consumesMultipleDataSets?.(appConfig); + if (shareType === SharedDataSet && !allowsMultiple) { dataSetsToRemove = sharedModelManager.getTileSharedModelsByType(consumerTile, SharedDataSet); } if (modelToShare){ @@ -105,7 +108,7 @@ export const useConsumerTileLinking = ({ }); } } - }, [model.content, modelToShare, readOnly, shareType, sharedModelManager]); + }, [appConfig, model.content, modelToShare, readOnly, shareType, sharedModelManager]); const unlinkTile = useCallback((tileInfo: ITileLinkMetadata) => { const linkedTile = getTileContentById(model.content, tileInfo.id); diff --git a/src/models/tiles/geometry/geometry-registration.ts b/src/models/tiles/geometry/geometry-registration.ts index a44b8a7850..edb91f0781 100644 --- a/src/models/tiles/geometry/geometry-registration.ts +++ b/src/models/tiles/geometry/geometry-registration.ts @@ -24,7 +24,7 @@ registerTileContentInfo({ defaultHeight: kGeometryDefaultHeight, exportNonDefaultHeight: true, isDataConsumer: true, - consumesMultipleDataSets: true, + consumesMultipleDataSets: () => true, defaultContent: defaultGeometryContent, tileSnapshotPreProcessor }); diff --git a/src/models/tiles/tile-content-info.ts b/src/models/tiles/tile-content-info.ts index 35f872286a..3e74a91ab4 100644 --- a/src/models/tiles/tile-content-info.ts +++ b/src/models/tiles/tile-content-info.ts @@ -59,7 +59,7 @@ export interface ITileContentInfo { isDataConsumer?: boolean; isDataProvider?: boolean; isVariableProvider?: boolean; - consumesMultipleDataSets?: boolean; + consumesMultipleDataSets?: (appConfig: AppConfigModelType) => boolean; tileSnapshotPreProcessor?: TileModelSnapshotPreProcessor; contentSnapshotPostProcessor?: TileContentSnapshotPostProcessor; updateContentWithNewSharedModelIds?: TileContentNewSharedModelIdUpdater; diff --git a/src/plugins/graph/graph-registration.ts b/src/plugins/graph/graph-registration.ts index 367b311f20..7d050940b6 100644 --- a/src/plugins/graph/graph-registration.ts +++ b/src/plugins/graph/graph-registration.ts @@ -8,6 +8,11 @@ import { updateGraphContentWithNewSharedModelIds, updateGraphObjectWithNewShared import Icon from "./assets/graph-icon.svg"; import HeaderIcon from "./assets/graph-tile-id.svg"; +import { AppConfigModelType } from "../../models/stores/app-config-model"; + +function graphAllowsMultipleDataSets(appConfig: AppConfigModelType) { + return !!appConfig.getSetting("defaultSeriesLegend", "graph"); +} registerTileContentInfo({ defaultContent: (options) => createGraphModel(undefined, options?.appConfig), @@ -16,6 +21,7 @@ registerTileContentInfo({ displayName: "Graph", type: kGraphTileType, isDataConsumer: true, + consumesMultipleDataSets: graphAllowsMultipleDataSets, updateContentWithNewSharedModelIds: updateGraphContentWithNewSharedModelIds, updateObjectReferenceWithNewSharedModelIds: updateGraphObjectWithNewSharedModelIds }); diff --git a/src/plugins/graph/models/graph-model.ts b/src/plugins/graph/models/graph-model.ts index dc21fd42be..85745a0c30 100644 --- a/src/plugins/graph/models/graph-model.ts +++ b/src/plugins/graph/models/graph-model.ts @@ -790,9 +790,7 @@ export function createGraphModel(snap?: IGraphModelSnapshot, appConfig?: AppConf yAttributeLabel: axisLabels && axisLabels.left, ...snap }); - // TODO: make a dedicated setting for this rather than using defaultSeriesLegend as a proxy: - // const connectLinesByDefault = appConfig?.getSetting("defaultConnectedLines", "graph"); - const connectByDefault = appConfig?.getSetting("defaultSeriesLegend", "graph"); + const connectByDefault = appConfig?.getSetting("connectPointsByDefault", "graph"); if (connectByDefault) { const cLines = ConnectingLinesModel.create(); createdGraphModel.addAdornment(cLines);