Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rename viz_config to viz_data_config #1146

Merged
merged 9 commits into from
Jan 27, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
76 changes: 38 additions & 38 deletions docs/generated/PROTOCOL_BUFFERS.md
Original file line number Diff line number Diff line change
Expand Up @@ -101,17 +101,17 @@
- [value.proto](#value-proto)
- [Value](#tanagra-Value)

- [viz/viz_config.proto](#viz_viz_config-proto)
- [VizConfig](#tanagra-viz-VizConfig)
- [VizConfig.Source](#tanagra-viz-VizConfig-Source)
- [VizConfig.Source.Attribute](#tanagra-viz-VizConfig-Source-Attribute)
- [VizConfig.Source.Attribute.NumericBucketing](#tanagra-viz-VizConfig-Source-Attribute-NumericBucketing)
- [VizConfig.Source.Attribute.NumericBucketing.Intervals](#tanagra-viz-VizConfig-Source-Attribute-NumericBucketing-Intervals)
- [VizConfig.Source.Join](#tanagra-viz-VizConfig-Source-Join)
- [VizConfig.Source.Join.Aggregation](#tanagra-viz-VizConfig-Source-Join-Aggregation)
- [viz/viz_data_config.proto](#viz_viz_data_config-proto)
- [VizDataConfig](#tanagra-viz-VizDataConfig)
- [VizDataConfig.Source](#tanagra-viz-VizDataConfig-Source)
- [VizDataConfig.Source.Attribute](#tanagra-viz-VizDataConfig-Source-Attribute)
- [VizDataConfig.Source.Attribute.NumericBucketing](#tanagra-viz-VizDataConfig-Source-Attribute-NumericBucketing)
- [VizDataConfig.Source.Attribute.NumericBucketing.Intervals](#tanagra-viz-VizDataConfig-Source-Attribute-NumericBucketing-Intervals)
- [VizDataConfig.Source.Join](#tanagra-viz-VizDataConfig-Source-Join)
- [VizDataConfig.Source.Join.Aggregation](#tanagra-viz-VizDataConfig-Source-Join-Aggregation)

- [VizConfig.Source.Attribute.SortType](#tanagra-viz-VizConfig-Source-Attribute-SortType)
- [VizConfig.Source.Join.Aggregation.AggregationType](#tanagra-viz-VizConfig-Source-Join-Aggregation-AggregationType)
- [VizDataConfig.Source.Attribute.SortType](#tanagra-viz-VizDataConfig-Source-Attribute-SortType)
- [VizDataConfig.Source.Join.Aggregation.AggregationType](#tanagra-viz-VizDataConfig-Source-Join-Aggregation-AggregationType)

- [Scalar Value Types](#scalar-value-types)

Expand Down Expand Up @@ -1270,31 +1270,31 @@ A single selected categorical value (e.g. {value: 1234, name: "Diabetes"



<a name="viz_viz_config-proto"></a>
<a name="viz_viz_data_config-proto"></a>
<p align="right"><a href="#top">Top</a></p>

## viz/viz_config.proto
## viz/viz_data_config.proto



<a name="tanagra-viz-VizConfig"></a>
<a name="tanagra-viz-VizDataConfig"></a>

### VizConfig
### VizDataConfig
The configuration of a underlay or cohort level visualization.


| Field | Type | Label | Description |
| ----- | ---- | ----- | ----------- |
| sources | [VizConfig.Source](#tanagra-viz-VizConfig-Source) | repeated | The visualization must have one or two sources of data to display. |
| sources | [VizDataConfig.Source](#tanagra-viz-VizDataConfig-Source) | repeated | The visualization must have one or two sources of data to display. |






<a name="tanagra-viz-VizConfig-Source"></a>
<a name="tanagra-viz-VizDataConfig-Source"></a>

### VizConfig.Source
### VizDataConfig.Source



Expand All @@ -1303,25 +1303,25 @@ The configuration of a underlay or cohort level visualization.
| criteriaSelector | [string](#string) | | The criteria selector (e.g. condition) determines which entities the data is being pulled from. |
| selectionData | [string](#string) | optional | Configuration of the specified criteria selection (e.g. to select conditions under diabetes). |
| entity | [string](#string) | optional | For criteria selectors that return more than one entity. |
| joins | [VizConfig.Source.Join](#tanagra-viz-VizConfig-Source-Join) | repeated | To visualize data from different entities, the data must be joined to a common entity. Each source must specify a series of joins that ends up at the same entity if it does not already come from that entity. |
| attributes | [VizConfig.Source.Attribute](#tanagra-viz-VizConfig-Source-Attribute) | repeated | Which attributes should be returned from the selected data source (e.g. condition_name from condition_occurrence or age from person). |
| joins | [VizDataConfig.Source.Join](#tanagra-viz-VizDataConfig-Source-Join) | repeated | To visualize data from different entities, the data must be joined to a common entity. Each source must specify a series of joins that ends up at the same entity if it does not already come from that entity. |
| attributes | [VizDataConfig.Source.Attribute](#tanagra-viz-VizDataConfig-Source-Attribute) | repeated | Which attributes should be returned from the selected data source (e.g. condition_name from condition_occurrence or age from person). |






<a name="tanagra-viz-VizConfig-Source-Attribute"></a>
<a name="tanagra-viz-VizDataConfig-Source-Attribute"></a>

### VizConfig.Source.Attribute
### VizDataConfig.Source.Attribute



| Field | Type | Label | Description |
| ----- | ---- | ----- | ----------- |
| attribute | [string](#string) | | The attribute to read. |
| numeric_bucketing | [VizConfig.Source.Attribute.NumericBucketing](#tanagra-viz-VizConfig-Source-Attribute-NumericBucketing) | | |
| sort_type | [VizConfig.Source.Attribute.SortType](#tanagra-viz-VizConfig-Source-Attribute-SortType) | optional | How to sort this attribute for display. Defaults to NAME. |
| numeric_bucketing | [VizDataConfig.Source.Attribute.NumericBucketing](#tanagra-viz-VizDataConfig-Source-Attribute-NumericBucketing) | | |
| sort_type | [VizDataConfig.Source.Attribute.SortType](#tanagra-viz-VizDataConfig-Source-Attribute-SortType) | optional | How to sort this attribute for display. Defaults to NAME. |
| sort_descending | [bool](#bool) | optional | Whether to sort in descending order. |
| limit | [int64](#int64) | optional | Whether a limited amount of data should be returned (e.g. 10 most common conditions). |

Expand All @@ -1330,16 +1330,16 @@ The configuration of a underlay or cohort level visualization.



<a name="tanagra-viz-VizConfig-Source-Attribute-NumericBucketing"></a>
<a name="tanagra-viz-VizDataConfig-Source-Attribute-NumericBucketing"></a>

### VizConfig.Source.Attribute.NumericBucketing
### VizDataConfig.Source.Attribute.NumericBucketing
Converts a continuous numeric range into ids with count as the value.


| Field | Type | Label | Description |
| ----- | ---- | ----- | ----------- |
| thresholds | [double](#double) | repeated | Buckets can be specified as either a list of thresholds or a range and number of buckets. For thresholds [18, 45, 65], results in two buckets [18, 45), and [45, 65). Lesser and greater buckets can be added if desired. |
| intervals | [VizConfig.Source.Attribute.NumericBucketing.Intervals](#tanagra-viz-VizConfig-Source-Attribute-NumericBucketing-Intervals) | optional | |
| intervals | [VizDataConfig.Source.Attribute.NumericBucketing.Intervals](#tanagra-viz-VizDataConfig-Source-Attribute-NumericBucketing-Intervals) | optional | |
| includeLesser | [bool](#bool) | optional | Whether to create buckets for values outside of the explicitly specified ones or ignore them. |
| includeGreater | [bool](#bool) | optional | |

Expand All @@ -1348,9 +1348,9 @@ Converts a continuous numeric range into ids with count as the value.



<a name="tanagra-viz-VizConfig-Source-Attribute-NumericBucketing-Intervals"></a>
<a name="tanagra-viz-VizDataConfig-Source-Attribute-NumericBucketing-Intervals"></a>

### VizConfig.Source.Attribute.NumericBucketing.Intervals
### VizDataConfig.Source.Attribute.NumericBucketing.Intervals
For intervals {min:1, max:5, count: 2}, creates two buckets [1, 3)
and [3, 5).

Expand All @@ -1366,31 +1366,31 @@ and [3, 5).



<a name="tanagra-viz-VizConfig-Source-Join"></a>
<a name="tanagra-viz-VizDataConfig-Source-Join"></a>

### VizConfig.Source.Join
### VizDataConfig.Source.Join



| Field | Type | Label | Description |
| ----- | ---- | ----- | ----------- |
| entity | [string](#string) | | The next entity to join to in order to eventually get to the entity the visualization is displaying (e.g. person when joining condition_occurences to age). |
| aggregation | [VizConfig.Source.Join.Aggregation](#tanagra-viz-VizConfig-Source-Join-Aggregation) | optional | When joining an entity with an N:1 relationship (e.g. multiple weight values to a person), an aggregation is often required to make the data visualizable. For example, to visualize weight vs. race, each person needs to have a single weight value associated with them, such as the average or most recent. For simple cases, simply counting unique instances of a related entity may be sufficient (e.g. to count people with related condition occurrences). |
| aggregation | [VizDataConfig.Source.Join.Aggregation](#tanagra-viz-VizDataConfig-Source-Join-Aggregation) | optional | When joining an entity with an N:1 relationship (e.g. multiple weight values to a person), an aggregation is often required to make the data visualizable. For example, to visualize weight vs. race, each person needs to have a single weight value associated with them, such as the average or most recent. For simple cases, simply counting unique instances of a related entity may be sufficient (e.g. to count people with related condition occurrences). |






<a name="tanagra-viz-VizConfig-Source-Join-Aggregation"></a>
<a name="tanagra-viz-VizDataConfig-Source-Join-Aggregation"></a>

### VizConfig.Source.Join.Aggregation
### VizDataConfig.Source.Join.Aggregation



| Field | Type | Label | Description |
| ----- | ---- | ----- | ----------- |
| type | [VizConfig.Source.Join.Aggregation.AggregationType](#tanagra-viz-VizConfig-Source-Join-Aggregation-AggregationType) | optional | The type of aggregation being performed. |
| type | [VizDataConfig.Source.Join.Aggregation.AggregationType](#tanagra-viz-VizDataConfig-Source-Join-Aggregation-AggregationType) | optional | The type of aggregation being performed. |
| attribute | [string](#string) | optional | The output is always ids and values but aggregation may occur over another field (e.g. date to find the most recent value). |


Expand All @@ -1400,9 +1400,9 @@ and [3, 5).



<a name="tanagra-viz-VizConfig-Source-Attribute-SortType"></a>
<a name="tanagra-viz-VizDataConfig-Source-Attribute-SortType"></a>

### VizConfig.Source.Attribute.SortType
### VizDataConfig.Source.Attribute.SortType


| Name | Number | Description |
Expand All @@ -1413,9 +1413,9 @@ and [3, 5).



<a name="tanagra-viz-VizConfig-Source-Join-Aggregation-AggregationType"></a>
<a name="tanagra-viz-VizDataConfig-Source-Join-Aggregation-AggregationType"></a>

### VizConfig.Source.Join.Aggregation.AggregationType
### VizDataConfig.Source.Join.Aggregation.AggregationType


| Name | Number | Description |
Expand Down
2 changes: 1 addition & 1 deletion docs/generated/UNDERLAY_CONFIG.md
Original file line number Diff line number Diff line change
Expand Up @@ -1328,7 +1328,7 @@ Configuration for a single visualization.
### SZVisualization.dataConfig
**required** String

Serialized configuration of the visualization. VizConfig protocol buffer as JSON.
Serialized configuration of the visualization. VizDataConfig protocol buffer as JSON.

### SZVisualization.dataConfigFile
**required** String
Expand Down
4 changes: 2 additions & 2 deletions ui/src/tanagra-underlay/underlayConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ export enum SZCorePlugin {
SURVEY = "SURVEY",
TEXT_SEARCH = "TEXT_SEARCH",
UNHINTED_VALUE = "UNHINTED_VALUE",
};
}

export type SZCriteriaOccurrence = {
criteriaEntity: string;
Expand Down Expand Up @@ -88,7 +88,7 @@ export enum SZDataType {
INT64 = "INT64",
STRING = "STRING",
TIMESTAMP = "TIMESTAMP",
};
}

export type SZDataflow = {
dataflowLocation: string;
Expand Down
12 changes: 7 additions & 5 deletions ui/src/viz/viz.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { VALUE_SUFFIX } from "data/configuration";
import { FilterCountValue } from "data/source";
import { compareDataValues } from "data/types";
import * as vizProto from "proto/viz/viz_config";
import * as vizProto from "proto/viz/viz_data_config";
import { useMemo } from "react";
import { isValid } from "util/valid";

Expand Down Expand Up @@ -48,10 +48,10 @@ export type VizDataFormat = {
};

export function processFilterCountValues(
vizConfig: vizProto.VizConfig,
vizDataConfig: vizProto.VizDataConfig,
fcvs: FilterCountValue[]
): VizData[] {
const vizSource = vizConfig.sources[0];
const vizSource = vizDataConfig.sources[0];

const dataMap = new Map<string, VizData>();
fcvs.forEach((d) => {
Expand Down Expand Up @@ -149,11 +149,13 @@ export function processFilterCountValues(
if (!attrib.numericBucketing) {
if (
!attrib.sortType ||
attrib.sortType === vizProto.VizConfig_Source_Attribute_SortType.NAME
attrib.sortType ===
vizProto.VizDataConfig_Source_Attribute_SortType.NAME
) {
sortValue = compareDataValues(a.keys[i].name, b.keys[i].name);
} else if (
attrib.sortType === vizProto.VizConfig_Source_Attribute_SortType.VALUE
attrib.sortType ===
vizProto.VizDataConfig_Source_Attribute_SortType.VALUE
) {
sortValue = compareDataValues(
a.values[i].numeric,
Expand Down
14 changes: 7 additions & 7 deletions ui/src/viz/vizContainer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import { useCohort, useStudyId } from "hooks";
import emptyImage from "images/empty.svg";
import { GridBox, GridBoxPaper } from "layout/gridBox";
import GridLayout from "layout/gridLayout";
import * as configProto from "proto/viz/viz_config";
import * as configProto from "proto/viz/viz_data_config";
import { useMemo, useState } from "react";
import useSWRImmutable from "swr/immutable";
import { getVizPlugin, processFilterCountValues, VizData } from "viz/viz";
Expand All @@ -24,7 +24,7 @@ type UnparsedConfig = {
};

type ParsedConfig = {
dataConfig: configProto.VizConfig;
dataConfig: configProto.VizDataConfig;
plugin: string;
pluginConfig: object;
title: string;
Expand All @@ -45,7 +45,7 @@ export function VizContainer(props: VizContainerProps) {
const config = useMemo(
(): ParsedConfig => ({
...props.config,
dataConfig: configProto.VizConfig.fromJSON(
dataConfig: configProto.VizDataConfig.fromJSON(
JSON.parse(props.config.dataConfig)
),
pluginConfig: JSON.parse(props.config.pluginConfig ?? "{}"),
Expand Down Expand Up @@ -134,16 +134,16 @@ const selectorToEntity: { [key: string]: string } = {
measurements: "measurementOccurrence",
};
async function fetchVizData(
vizConfig: configProto.VizConfig,
vizDataConfig: configProto.VizDataConfig,
studySource: StudySource,
studyId: string,
cohort: Cohort
): Promise<VizData[]> {
const vizSource = vizConfig.sources[0];
const vizSource = vizDataConfig.sources[0];

// TODO(tjennison): Remove these limitations once the backend sufficiently
// supports the query generation.
if (!vizSource || vizConfig.sources.length > 1) {
if (!vizSource || vizDataConfig.sources.length > 1) {
throw new Error("Only 1 visualization source is supported.");
}
const entity = selectorToEntity[vizSource.criteriaSelector];
Expand All @@ -165,5 +165,5 @@ async function fetchVizData(
countDistinctAttribute: vizSource.joins?.length ? "person_id" : undefined,
});

return processFilterCountValues(vizConfig, fcvs);
return processFilterCountValues(vizDataConfig, fcvs);
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public class SZVisualization {
@AnnotatedField(
name = "SZVisualization.dataConfig",
markdown =
"Serialized configuration of the visualization. VizConfig protocol buffer as JSON.")
"Serialized configuration of the visualization. VizDataConfig protocol buffer as JSON.")
public String dataConfig;

@AnnotatedField(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ option java_package = "bio.terra.tanagra.proto.viz";
option java_outer_classname = "Viz";

// The configuration of a underlay or cohort level visualization.
message VizConfig {
message VizDataConfig {
message Source {
// The criteria selector (e.g. condition) determines which entities the data
// is being pulled from.
Expand Down
Loading