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

Dimension description #716

Merged
merged 11 commits into from
Sep 16, 2022
19 changes: 13 additions & 6 deletions app/components/chart-filters-list.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Box, Typography } from "@mui/material";
import { Box, Typography, Tooltip } from "@mui/material";
import { Fragment } from "react";

import { useQueryFilters } from "@/charts/shared/chart-helpers";
Expand Down Expand Up @@ -73,14 +73,21 @@ export const ChartFiltersList = ({
>
{namedFilters.map(({ dimension, value }, i) => (
<Fragment key={dimension.iri}>
<Box component="span">
{dimension.label}
<Box component="span" fontWeight="bold">
{dimension.description ? (
<Tooltip arrow title={dimension.description}>
<span style={{ textDecoration: "underline" }}>
{dimension.label}
</span>
</Tooltip>
) : (
dimension.label
)}

{": "}
</Box>

<Box component="span" sx={{ fontWeight: "bold" }}>
{value && value.label}
</Box>
<Box component="span">{value && value.label}</Box>
{i < namedFilters.length - 1 && ", "}
</Fragment>
))}
Expand Down
22 changes: 19 additions & 3 deletions app/configurator/components/datatable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import {
SxProps,
Table,
TableBody,
Tooltip,
TableCell,
TableHead,
TableRow,
Expand All @@ -25,6 +26,23 @@ import { useLocale } from "@/locales/use-locale";

import { useDimensionFormatters } from "./ui-helpers";

const DimensionLabel = ({
dimension,
}: {
dimension: DimensionMetadataFragment;
}) => {
const label = dimension.unit
? `${dimension.label} (${dimension.unit})`
: dimension.label;
return dimension.description ? (
<Tooltip title={dimension.description} arrow>
<span style={{ textDecoration: "underline" }}>{label}</span>
</Tooltip>
) : (
<>{label}</>
);
};

export const PreviewTable = ({
title,
headers,
Expand Down Expand Up @@ -83,9 +101,7 @@ export const PreviewTable = ({
active={sortBy?.iri === header.iri}
direction={sortDirection}
>
{header.unit
? `${header.label} (${header.unit})`
: header.label}
<DimensionLabel dimension={header} />
</TableSortLabel>
</TableCell>
);
Expand Down
2 changes: 1 addition & 1 deletion app/docs/components.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { markdown } from "catalog";

const Doc = () => markdown`
> The components used in the User Interface are built upon [rebass](https://rebassjs.org/), a library of React primitive UI components.
> The components used in the User Interface are built upon [rebass](https://mui.com/), a library of React UI components.
bprusinowski marked this conversation as resolved.
Show resolved Hide resolved
ptbrowne marked this conversation as resolved.
Show resolved Hide resolved

> All styles are defined in a \`theme\` file [that can be customized to a specific brand](/theming).

Expand Down
18 changes: 18 additions & 0 deletions app/docs/tooltips.docs.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import { Tooltip, Typography } from "@mui/material";
import { markdown, ReactSpecimen } from "catalog";

const Doc = () => markdown`
Tooltips are used to provide more information.

${(
<ReactSpecimen span={2}>
<Tooltip title="I have a tooltip" arrow open>
<Typography display="inline" variant="body2">
Content with tooltip
</Typography>
</Tooltip>
</ReactSpecimen>
)}
`;

export default Doc;
1 change: 1 addition & 0 deletions app/graphql/queries/data-cubes.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ query DataCubes(
fragment dimensionMetadata on Dimension {
iri
label
description
isNumerical
isKeyDimension
order
Expand Down
20 changes: 14 additions & 6 deletions app/graphql/query-hooks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ export type DatasetCount = {
export type Dimension = {
iri: Scalars['String'];
label: Scalars['String'];
description?: Maybe<Scalars['String']>;
unit?: Maybe<Scalars['String']>;
scaleType?: Maybe<Scalars['String']>;
order?: Maybe<Scalars['Int']>;
Expand Down Expand Up @@ -154,6 +155,7 @@ export type GeoCoordinatesDimension = Dimension & {
__typename: 'GeoCoordinatesDimension';
iri: Scalars['String'];
label: Scalars['String'];
description?: Maybe<Scalars['String']>;
unit?: Maybe<Scalars['String']>;
scaleType?: Maybe<Scalars['String']>;
order?: Maybe<Scalars['Int']>;
Expand Down Expand Up @@ -183,6 +185,7 @@ export type GeoShapesDimension = Dimension & {
__typename: 'GeoShapesDimension';
iri: Scalars['String'];
label: Scalars['String'];
description?: Maybe<Scalars['String']>;
unit?: Maybe<Scalars['String']>;
scaleType?: Maybe<Scalars['String']>;
order?: Maybe<Scalars['Int']>;
Expand Down Expand Up @@ -221,6 +224,7 @@ export type Measure = Dimension & {
__typename: 'Measure';
iri: Scalars['String'];
label: Scalars['String'];
description?: Maybe<Scalars['String']>;
unit?: Maybe<Scalars['String']>;
scaleType?: Maybe<Scalars['String']>;
order?: Maybe<Scalars['Int']>;
Expand Down Expand Up @@ -251,6 +255,7 @@ export type NominalDimension = Dimension & {
__typename: 'NominalDimension';
iri: Scalars['String'];
label: Scalars['String'];
description?: Maybe<Scalars['String']>;
unit?: Maybe<Scalars['String']>;
scaleType?: Maybe<Scalars['String']>;
order?: Maybe<Scalars['Int']>;
Expand Down Expand Up @@ -298,6 +303,7 @@ export type OrdinalDimension = Dimension & {
__typename: 'OrdinalDimension';
iri: Scalars['String'];
label: Scalars['String'];
description?: Maybe<Scalars['String']>;
unit?: Maybe<Scalars['String']>;
scaleType?: Maybe<Scalars['String']>;
order?: Maybe<Scalars['Int']>;
Expand Down Expand Up @@ -404,6 +410,7 @@ export type TemporalDimension = Dimension & {
__typename: 'TemporalDimension';
iri: Scalars['String'];
label: Scalars['String'];
description?: Maybe<Scalars['String']>;
timeUnit: TimeUnit;
timeFormat: Scalars['String'];
unit?: Maybe<Scalars['String']>;
Expand Down Expand Up @@ -453,32 +460,32 @@ export type DataCubesQueryVariables = Exact<{
export type DataCubesQuery = { __typename: 'Query', dataCubes: Array<{ __typename: 'DataCubeResult', highlightedTitle?: Maybe<string>, highlightedDescription?: Maybe<string>, dataCube: { __typename: 'DataCube', iri: string, title: string, workExamples?: Maybe<Array<Maybe<string>>>, description?: Maybe<string>, publicationStatus: DataCubePublicationStatus, datePublished?: Maybe<string>, creator?: Maybe<{ __typename: 'DataCubeOrganization', iri: string, label?: Maybe<string> }>, themes: Array<{ __typename: 'DataCubeTheme', iri: string, label?: Maybe<string> }> } }> };

type DimensionMetadata_GeoCoordinatesDimension_Fragment = (
{ __typename: 'GeoCoordinatesDimension', iri: string, label: string, isNumerical: boolean, isKeyDimension: boolean, order?: Maybe<number>, values: Array<any>, unit?: Maybe<string>, related?: Maybe<Array<{ __typename: 'RelatedDimension', iri: string, type: string }>> }
{ __typename: 'GeoCoordinatesDimension', iri: string, label: string, description?: Maybe<string>, isNumerical: boolean, isKeyDimension: boolean, order?: Maybe<number>, values: Array<any>, unit?: Maybe<string>, related?: Maybe<Array<{ __typename: 'RelatedDimension', iri: string, type: string }>> }
& HierarchyMetadata_GeoCoordinatesDimension_Fragment
);

type DimensionMetadata_GeoShapesDimension_Fragment = (
{ __typename: 'GeoShapesDimension', iri: string, label: string, isNumerical: boolean, isKeyDimension: boolean, order?: Maybe<number>, values: Array<any>, unit?: Maybe<string>, related?: Maybe<Array<{ __typename: 'RelatedDimension', iri: string, type: string }>> }
{ __typename: 'GeoShapesDimension', iri: string, label: string, description?: Maybe<string>, isNumerical: boolean, isKeyDimension: boolean, order?: Maybe<number>, values: Array<any>, unit?: Maybe<string>, related?: Maybe<Array<{ __typename: 'RelatedDimension', iri: string, type: string }>> }
& HierarchyMetadata_GeoShapesDimension_Fragment
);

type DimensionMetadata_Measure_Fragment = (
{ __typename: 'Measure', isCurrency?: Maybe<boolean>, currencyExponent?: Maybe<number>, resolution?: Maybe<number>, iri: string, label: string, isNumerical: boolean, isKeyDimension: boolean, order?: Maybe<number>, values: Array<any>, unit?: Maybe<string>, related?: Maybe<Array<{ __typename: 'RelatedDimension', iri: string, type: string }>> }
{ __typename: 'Measure', isCurrency?: Maybe<boolean>, currencyExponent?: Maybe<number>, resolution?: Maybe<number>, iri: string, label: string, description?: Maybe<string>, isNumerical: boolean, isKeyDimension: boolean, order?: Maybe<number>, values: Array<any>, unit?: Maybe<string>, related?: Maybe<Array<{ __typename: 'RelatedDimension', iri: string, type: string }>> }
& HierarchyMetadata_Measure_Fragment
);

type DimensionMetadata_NominalDimension_Fragment = (
{ __typename: 'NominalDimension', iri: string, label: string, isNumerical: boolean, isKeyDimension: boolean, order?: Maybe<number>, values: Array<any>, unit?: Maybe<string>, related?: Maybe<Array<{ __typename: 'RelatedDimension', iri: string, type: string }>> }
{ __typename: 'NominalDimension', iri: string, label: string, description?: Maybe<string>, isNumerical: boolean, isKeyDimension: boolean, order?: Maybe<number>, values: Array<any>, unit?: Maybe<string>, related?: Maybe<Array<{ __typename: 'RelatedDimension', iri: string, type: string }>> }
& HierarchyMetadata_NominalDimension_Fragment
);

type DimensionMetadata_OrdinalDimension_Fragment = (
{ __typename: 'OrdinalDimension', iri: string, label: string, isNumerical: boolean, isKeyDimension: boolean, order?: Maybe<number>, values: Array<any>, unit?: Maybe<string>, related?: Maybe<Array<{ __typename: 'RelatedDimension', iri: string, type: string }>> }
{ __typename: 'OrdinalDimension', iri: string, label: string, description?: Maybe<string>, isNumerical: boolean, isKeyDimension: boolean, order?: Maybe<number>, values: Array<any>, unit?: Maybe<string>, related?: Maybe<Array<{ __typename: 'RelatedDimension', iri: string, type: string }>> }
& HierarchyMetadata_OrdinalDimension_Fragment
);

type DimensionMetadata_TemporalDimension_Fragment = (
{ __typename: 'TemporalDimension', timeUnit: TimeUnit, timeFormat: string, iri: string, label: string, isNumerical: boolean, isKeyDimension: boolean, order?: Maybe<number>, values: Array<any>, unit?: Maybe<string>, related?: Maybe<Array<{ __typename: 'RelatedDimension', iri: string, type: string }>> }
{ __typename: 'TemporalDimension', timeUnit: TimeUnit, timeFormat: string, iri: string, label: string, description?: Maybe<string>, isNumerical: boolean, isKeyDimension: boolean, order?: Maybe<number>, values: Array<any>, unit?: Maybe<string>, related?: Maybe<Array<{ __typename: 'RelatedDimension', iri: string, type: string }>> }
& HierarchyMetadata_TemporalDimension_Fragment
);

Expand Down Expand Up @@ -882,6 +889,7 @@ export const DimensionMetadataFragmentDoc = gql`
fragment dimensionMetadata on Dimension {
iri
label
description
isNumerical
isKeyDimension
order
Expand Down
14 changes: 14 additions & 0 deletions app/graphql/resolver-types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@ export type DatasetCount = {
export type Dimension = {
iri: Scalars['String'];
label: Scalars['String'];
description?: Maybe<Scalars['String']>;
unit?: Maybe<Scalars['String']>;
scaleType?: Maybe<Scalars['String']>;
order?: Maybe<Scalars['Int']>;
Expand Down Expand Up @@ -160,6 +161,7 @@ export type GeoCoordinatesDimension = Dimension & {
__typename?: 'GeoCoordinatesDimension';
iri: Scalars['String'];
label: Scalars['String'];
description?: Maybe<Scalars['String']>;
unit?: Maybe<Scalars['String']>;
scaleType?: Maybe<Scalars['String']>;
order?: Maybe<Scalars['Int']>;
Expand Down Expand Up @@ -189,6 +191,7 @@ export type GeoShapesDimension = Dimension & {
__typename?: 'GeoShapesDimension';
iri: Scalars['String'];
label: Scalars['String'];
description?: Maybe<Scalars['String']>;
unit?: Maybe<Scalars['String']>;
scaleType?: Maybe<Scalars['String']>;
order?: Maybe<Scalars['Int']>;
Expand Down Expand Up @@ -227,6 +230,7 @@ export type Measure = Dimension & {
__typename?: 'Measure';
iri: Scalars['String'];
label: Scalars['String'];
description?: Maybe<Scalars['String']>;
unit?: Maybe<Scalars['String']>;
scaleType?: Maybe<Scalars['String']>;
order?: Maybe<Scalars['Int']>;
Expand Down Expand Up @@ -257,6 +261,7 @@ export type NominalDimension = Dimension & {
__typename?: 'NominalDimension';
iri: Scalars['String'];
label: Scalars['String'];
description?: Maybe<Scalars['String']>;
unit?: Maybe<Scalars['String']>;
scaleType?: Maybe<Scalars['String']>;
order?: Maybe<Scalars['Int']>;
Expand Down Expand Up @@ -304,6 +309,7 @@ export type OrdinalDimension = Dimension & {
__typename?: 'OrdinalDimension';
iri: Scalars['String'];
label: Scalars['String'];
description?: Maybe<Scalars['String']>;
unit?: Maybe<Scalars['String']>;
scaleType?: Maybe<Scalars['String']>;
order?: Maybe<Scalars['Int']>;
Expand Down Expand Up @@ -410,6 +416,7 @@ export type TemporalDimension = Dimension & {
__typename?: 'TemporalDimension';
iri: Scalars['String'];
label: Scalars['String'];
description?: Maybe<Scalars['String']>;
timeUnit: TimeUnit;
timeFormat: Scalars['String'];
unit?: Maybe<Scalars['String']>;
Expand Down Expand Up @@ -631,6 +638,7 @@ export type DimensionResolvers<ContextType = GraphQLContext, ParentType extends
__resolveType: TypeResolveFn<'GeoCoordinatesDimension' | 'GeoShapesDimension' | 'Measure' | 'NominalDimension' | 'OrdinalDimension' | 'TemporalDimension', ParentType, ContextType>;
iri?: Resolver<ResolversTypes['String'], ParentType, ContextType>;
label?: Resolver<ResolversTypes['String'], ParentType, ContextType>;
description?: Resolver<Maybe<ResolversTypes['String']>, ParentType, ContextType>;
unit?: Resolver<Maybe<ResolversTypes['String']>, ParentType, ContextType>;
scaleType?: Resolver<Maybe<ResolversTypes['String']>, ParentType, ContextType>;
order?: Resolver<Maybe<ResolversTypes['Int']>, ParentType, ContextType>;
Expand Down Expand Up @@ -664,6 +672,7 @@ export type GeoCoordinatesResolvers<ContextType = GraphQLContext, ParentType ext
export type GeoCoordinatesDimensionResolvers<ContextType = GraphQLContext, ParentType extends ResolversParentTypes['GeoCoordinatesDimension'] = ResolversParentTypes['GeoCoordinatesDimension']> = ResolversObject<{
iri?: Resolver<ResolversTypes['String'], ParentType, ContextType>;
label?: Resolver<ResolversTypes['String'], ParentType, ContextType>;
description?: Resolver<Maybe<ResolversTypes['String']>, ParentType, ContextType>;
unit?: Resolver<Maybe<ResolversTypes['String']>, ParentType, ContextType>;
scaleType?: Resolver<Maybe<ResolversTypes['String']>, ParentType, ContextType>;
order?: Resolver<Maybe<ResolversTypes['Int']>, ParentType, ContextType>;
Expand All @@ -683,6 +692,7 @@ export interface GeoShapesScalarConfig extends GraphQLScalarTypeConfig<Resolvers
export type GeoShapesDimensionResolvers<ContextType = GraphQLContext, ParentType extends ResolversParentTypes['GeoShapesDimension'] = ResolversParentTypes['GeoShapesDimension']> = ResolversObject<{
iri?: Resolver<ResolversTypes['String'], ParentType, ContextType>;
label?: Resolver<ResolversTypes['String'], ParentType, ContextType>;
description?: Resolver<Maybe<ResolversTypes['String']>, ParentType, ContextType>;
unit?: Resolver<Maybe<ResolversTypes['String']>, ParentType, ContextType>;
scaleType?: Resolver<Maybe<ResolversTypes['String']>, ParentType, ContextType>;
order?: Resolver<Maybe<ResolversTypes['Int']>, ParentType, ContextType>;
Expand All @@ -708,6 +718,7 @@ export type HierarchyValueResolvers<ContextType = GraphQLContext, ParentType ext
export type MeasureResolvers<ContextType = GraphQLContext, ParentType extends ResolversParentTypes['Measure'] = ResolversParentTypes['Measure']> = ResolversObject<{
iri?: Resolver<ResolversTypes['String'], ParentType, ContextType>;
label?: Resolver<ResolversTypes['String'], ParentType, ContextType>;
description?: Resolver<Maybe<ResolversTypes['String']>, ParentType, ContextType>;
unit?: Resolver<Maybe<ResolversTypes['String']>, ParentType, ContextType>;
scaleType?: Resolver<Maybe<ResolversTypes['String']>, ParentType, ContextType>;
order?: Resolver<Maybe<ResolversTypes['Int']>, ParentType, ContextType>;
Expand All @@ -725,6 +736,7 @@ export type MeasureResolvers<ContextType = GraphQLContext, ParentType extends Re
export type NominalDimensionResolvers<ContextType = GraphQLContext, ParentType extends ResolversParentTypes['NominalDimension'] = ResolversParentTypes['NominalDimension']> = ResolversObject<{
iri?: Resolver<ResolversTypes['String'], ParentType, ContextType>;
label?: Resolver<ResolversTypes['String'], ParentType, ContextType>;
description?: Resolver<Maybe<ResolversTypes['String']>, ParentType, ContextType>;
unit?: Resolver<Maybe<ResolversTypes['String']>, ParentType, ContextType>;
scaleType?: Resolver<Maybe<ResolversTypes['String']>, ParentType, ContextType>;
order?: Resolver<Maybe<ResolversTypes['Int']>, ParentType, ContextType>;
Expand Down Expand Up @@ -758,6 +770,7 @@ export type ObservationsQueryResolvers<ContextType = GraphQLContext, ParentType
export type OrdinalDimensionResolvers<ContextType = GraphQLContext, ParentType extends ResolversParentTypes['OrdinalDimension'] = ResolversParentTypes['OrdinalDimension']> = ResolversObject<{
iri?: Resolver<ResolversTypes['String'], ParentType, ContextType>;
label?: Resolver<ResolversTypes['String'], ParentType, ContextType>;
description?: Resolver<Maybe<ResolversTypes['String']>, ParentType, ContextType>;
unit?: Resolver<Maybe<ResolversTypes['String']>, ParentType, ContextType>;
scaleType?: Resolver<Maybe<ResolversTypes['String']>, ParentType, ContextType>;
order?: Resolver<Maybe<ResolversTypes['Int']>, ParentType, ContextType>;
Expand Down Expand Up @@ -792,6 +805,7 @@ export type RelatedDimensionResolvers<ContextType = GraphQLContext, ParentType e
export type TemporalDimensionResolvers<ContextType = GraphQLContext, ParentType extends ResolversParentTypes['TemporalDimension'] = ResolversParentTypes['TemporalDimension']> = ResolversObject<{
iri?: Resolver<ResolversTypes['String'], ParentType, ContextType>;
label?: Resolver<ResolversTypes['String'], ParentType, ContextType>;
description?: Resolver<Maybe<ResolversTypes['String']>, ParentType, ContextType>;
timeUnit?: Resolver<ResolversTypes['TimeUnit'], ParentType, ContextType>;
timeFormat?: Resolver<ResolversTypes['String'], ParentType, ContextType>;
unit?: Resolver<Maybe<ResolversTypes['String']>, ParentType, ContextType>;
Expand Down
1 change: 1 addition & 0 deletions app/graphql/resolvers/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ const mkDimensionResolvers = (_: string): Resolvers["Dimension"] => ({
},
iri: ({ data: { iri } }) => iri,
label: ({ data: { name } }) => name,
description: ({ data: { description } }) => description || null,
related: ({ data: { related } }) => related,
order: ({ data: { order } }) => (order !== undefined ? order : null),
isNumerical: ({ data: { isNumerical } }) => isNumerical,
Expand Down
7 changes: 7 additions & 0 deletions app/graphql/schema.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ type HierarchyValue {
interface Dimension {
iri: String!
label: String!
description: String
unit: String
scaleType: String
order: Int
Expand All @@ -94,6 +95,7 @@ type GeoCoordinates {
type GeoCoordinatesDimension implements Dimension {
iri: String!
label: String!
description: String
unit: String
scaleType: String
order: Int
Expand All @@ -118,6 +120,7 @@ type ObservationFilter {
type GeoShapesDimension implements Dimension {
iri: String!
label: String!
description: String
unit: String
scaleType: String
order: Int
Expand All @@ -136,6 +139,7 @@ type GeoShapesDimension implements Dimension {
type NominalDimension implements Dimension {
iri: String!
label: String!
description: String
unit: String
scaleType: String
order: Int
Expand All @@ -153,6 +157,7 @@ type NominalDimension implements Dimension {
type OrdinalDimension implements Dimension {
iri: String!
label: String!
description: String
unit: String
scaleType: String
order: Int
Expand Down Expand Up @@ -180,6 +185,7 @@ enum TimeUnit {
type TemporalDimension implements Dimension {
iri: String!
label: String!
description: String
timeUnit: TimeUnit!
timeFormat: String!
unit: String
Expand All @@ -199,6 +205,7 @@ type TemporalDimension implements Dimension {
type Measure implements Dimension {
iri: String!
label: String!
description: String
unit: String
scaleType: String
order: Int
Expand Down
1 change: 1 addition & 0 deletions app/graphql/shared-types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ export type ResolvedDimension = {
dataType?: string;
order?: number;
name: string;
description?: string;
dataKind?: "Time" | "GeoCoordinates" | "GeoShape";
related: Omit<RelatedDimension, "__typename">[];
timeUnit?: TimeUnit;
Expand Down
Loading