Skip to content
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
4 changes: 0 additions & 4 deletions packages/charts/api/charts.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -964,10 +964,6 @@ export interface GoalSpec extends Spec {
centralMinor: string | GoalLabelAccessor;
// (undocumented)
chartType: typeof ChartType.Goal;
// Warning: (ae-forgotten-export) The symbol "Config" needs to be exported by the entry point index.d.ts
//
// @deprecated (undocumented)
config?: RecursivePartial<Config>;
// (undocumented)
labelMajor: string | GoalLabelAccessor;
// (undocumented)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@ import { TAU } from '../../../../common/constants';
export const configMetadata: Record<string, ConfigItem> = {
angleStart: { dflt: Math.PI + Math.PI / 4, min: -TAU, max: TAU, type: 'number' },
angleEnd: { dflt: -Math.PI / 4, min: -TAU, max: TAU, type: 'number' },

// shape geometry
margin: {
type: 'group',
values: {
Expand All @@ -27,17 +25,12 @@ export const configMetadata: Record<string, ConfigItem> = {
bottom: { dflt: 0, min: -0.25, max: 0.25, type: 'number' },
},
},

// general text config
fontFamily: {
dflt: 'Sans-Serif',
type: 'string',
},

// fill text config
minFontSize: { dflt: 8, min: 0.1, max: 8, type: 'number', reconfigurable: true },
maxFontSize: { dflt: 64, min: 0.1, max: 64, type: 'number' },

backgroundColor: { dflt: '#ffffff', type: 'color' },
sectorLineWidth: { dflt: 1, min: 0, max: 4, type: 'number' },
};

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ export type PickFunction = (x: Pixels, y: Pixels) => Array<BulletViewModel>;

/** @internal */
export type ShapeViewModel = {
config: Theme['goal'];
theme: Theme['goal'];
bulletViewModel: BulletViewModel;
chartCenter: PointObject;
pickQuads: PickFunction;
Expand Down Expand Up @@ -101,7 +101,7 @@ export const nullGoalViewModel = {

/** @internal */
export const nullShapeViewModel = ({ goal }: Theme = LIGHT_THEME): ShapeViewModel => ({
config: goal,
theme: goal,
bulletViewModel: nullGoalViewModel,
chartCenter: { x: 0, y: 0 },
pickQuads: () => [],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ function get<T>(o: { [k: string]: any }, name: string, dflt: T) {
/** @internal */
export function geoms(
bulletViewModel: BulletViewModel,
config: Theme['goal'],
theme: Theme['goal'],
partentDimensions: Dimensions,
chartCenter: PointObject,
): Mark[] {
Expand Down Expand Up @@ -308,21 +308,21 @@ export function geoms(
{
order: 1,
landmarks: { from: 'base', to: 'actual', yOffset: 'yOffset' },
aes: { shape, fillColor: config.progressLine.stroke, lineWidth: tickLength },
aes: { shape, fillColor: theme.progressLine.stroke, lineWidth: tickLength },
},
...(target
? [
{
order: 2,
landmarks: { at: 'target', yOffset: 'yOffset' },
aes: { shape, fillColor: config.targetLine.stroke, lineWidth: barThickness / GOLDEN_RATIO },
aes: { shape, fillColor: theme.targetLine.stroke, lineWidth: barThickness / GOLDEN_RATIO },
},
]
: []),
...bulletViewModel.ticks.map((b, i) => ({
order: 3,
landmarks: { at: `tick_${i}`, yOffset: 'yOffset' },
aes: { shape, fillColor: config.tickLine.stroke, lineWidth: tickLength, axisNormalOffset: tickOffset },
aes: { shape, fillColor: theme.tickLine.stroke, lineWidth: tickLength, axisNormalOffset: tickOffset },
})),
...bulletViewModel.ticks.map((b, i) => ({
order: 4,
Expand All @@ -331,8 +331,8 @@ export function geoms(
shape: 'text',
textAlign: vertical ? 'right' : 'center',
textBaseline: vertical ? 'middle' : 'top',
fillColor: config.tickLabel.fill,
fontShape: { ...config.tickLabel, fontVariant: 'normal', fontWeight: '500' },
fillColor: theme.tickLabel.fill,
fontShape: { ...theme.tickLabel, fontVariant: 'normal', fontWeight: '500' },
axisNormalOffset: -barThickness,
},
})),
Expand All @@ -345,8 +345,8 @@ export function geoms(
axisTangentOffset: circular || !vertical ? 0 : 2 * labelFontSize,
textAlign: vertical ? 'center' : 'right',
textBaseline: 'bottom',
fillColor: config.majorLabel.fill,
fontShape: { ...config.majorLabel, fontVariant: 'normal', fontWeight: '900' },
fillColor: theme.majorLabel.fill,
fontShape: { ...theme.majorLabel, fontVariant: 'normal', fontWeight: '900' },
},
},
{
Expand All @@ -358,8 +358,8 @@ export function geoms(
axisTangentOffset: circular || !vertical ? 0 : 2 * labelFontSize,
textAlign: vertical ? 'center' : 'right',
textBaseline: 'top',
fillColor: config.minorLabel.fill,
fontShape: { ...config.minorLabel, fontVariant: 'normal', fontWeight: '300' },
fillColor: theme.minorLabel.fill,
fontShape: { ...theme.minorLabel, fontVariant: 'normal', fontWeight: '300' },
},
},
...(circular
Expand All @@ -371,8 +371,8 @@ export function geoms(
shape: 'text',
textAlign: 'center',
textBaseline: 'bottom',
fillColor: config.majorCenterLabel.fill,
fontShape: { ...config.majorCenterLabel, fontVariant: 'normal', fontWeight: '900' },
fillColor: theme.majorCenterLabel.fill,
fontShape: { ...theme.majorCenterLabel, fontVariant: 'normal', fontWeight: '900' },
},
},
{
Expand All @@ -382,8 +382,8 @@ export function geoms(
shape: 'text',
textAlign: 'center',
textBaseline: 'top',
fillColor: config.minorCenterLabel.fill,
fontShape: { ...config.minorCenterLabel, fontVariant: 'normal', fontWeight: '300' },
fillColor: theme.minorCenterLabel.fill,
fontShape: { ...theme.minorCenterLabel, fontVariant: 'normal', fontWeight: '300' },
},
},
]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ export function shapeViewModel(spec: GoalSpec, theme: Theme, chartDimensions: Di
: [];

return {
config: theme.goal,
theme: theme.goal,
chartCenter,
bulletViewModel,
pickQuads,
Expand Down
8 changes: 1 addition & 7 deletions packages/charts/src/chart_types/goal_chart/specs/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,7 @@ import { Color } from '../../../common/colors';
import { Spec } from '../../../specs';
import { SpecType } from '../../../specs/constants';
import { getConnect, specComponentFactory } from '../../../state/spec_factory';
import { LabelAccessor, RecursivePartial } from '../../../utils/common';
import { Config } from '../layout/types/config_types';
import { LabelAccessor } from '../../../utils/common';
import { defaultGoalSpec } from '../layout/types/viewmodel_types';
import { GoalSubtype } from './constants';

Expand Down Expand Up @@ -57,11 +56,6 @@ export interface GoalSpec extends Spec {
labelMinor: string | GoalLabelAccessor;
centralMajor: string | GoalLabelAccessor;
centralMinor: string | GoalLabelAccessor;
/**
* @deprecated properties have been migrated to the theme or spec.
* To be removed with partition, heatmap and wordmap configs.
*/
config?: RecursivePartial<Config>;
angleStart: number;
angleEnd: number;
bandLabels: string[];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ export const geometries = createCustomCachedSelector(
export const getPrimitiveGeoms = createCustomCachedSelector(
[geometries, getParentDimensions],
(shapeViewModel, parentDimensions): Mark[] => {
const { chartCenter, bulletViewModel, config } = shapeViewModel;
return geoms(bulletViewModel, config, parentDimensions, chartCenter);
const { chartCenter, bulletViewModel, theme } = shapeViewModel;
return geoms(bulletViewModel, theme, parentDimensions, chartCenter);
},
);
Original file line number Diff line number Diff line change
Expand Up @@ -6,43 +6,13 @@
* Side Public License, v 1.
*/

import { mergePartial, RecursivePartial } from '../../../../utils/common';
import { Dimensions } from '../../../../utils/dimensions';
import { PartialTheme, Theme } from '../../../../utils/themes/theme';
import { Config } from '../../layout/types/config_types';
import { Theme } from '../../../../utils/themes/theme';
import { ShapeViewModel } from '../../layout/types/viewmodel_types';
import { shapeViewModel } from '../../layout/viewmodel/viewmodel';
import { GoalSpec } from '../../specs';

/**
* Helper to map old config to theme
* remove when `spec.config` is fully deprecated
*/
const mapConfigToTheme = ({
margin,
backgroundColor,
minFontSize,
maxFontSize,
fontFamily,
}: RecursivePartial<Config> = {}): PartialTheme => ({
chartMargins: margin,
background: { color: backgroundColor },
goal: {
minFontSize,
maxFontSize,
tickLabel: { fontFamily },
majorLabel: { fontFamily },
minorLabel: { fontFamily },
},
});

/** @internal */
export function render(spec: GoalSpec, parentDimensions: Dimensions, theme: Theme): ShapeViewModel {
// override theme and spec with old deprecated config options
const mergedTheme: Theme = mergePartial(theme, mapConfigToTheme(spec.config));
const mergedSpec: GoalSpec = mergePartial(spec, {
angleEnd: spec?.config?.angleEnd,
angleStart: spec?.config?.angleStart,
});
return shapeViewModel(mergedSpec, mergedTheme, parentDimensions);
return shapeViewModel(spec, theme, parentDimensions);
}
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,8 @@ describe('Accessibility', () => {
labelMinor="(thousand USD) "
centralMajor="170"
centralMinor=""
config={{ angleStart: Math.PI, angleEnd: 0 }}
angleStart={Math.PI}
angleEnd={0}
/>
</Chart>,
);
Expand All @@ -161,7 +162,8 @@ describe('Accessibility', () => {
labelMinor="(thousand USD) "
centralMajor="170"
centralMinor=""
config={{ angleStart: Math.PI, angleEnd: 0 }}
angleStart={Math.PI}
angleEnd={0}
bandLabels={bandLabelsAscending}
/>
</Chart>,
Expand Down
3 changes: 2 additions & 1 deletion storybook/stories/goal/14_one_third.story.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,8 @@ export const Example = () => (
labelMinor=""
centralMajor="280 MB/s"
centralMinor=""
config={{ angleStart: Math.PI - (Math.PI - (2 * Math.PI) / 3) / 2, angleEnd: (Math.PI - (2 * Math.PI) / 3) / 2 }}
angleStart={Math.PI - (Math.PI - (2 * Math.PI) / 3) / 2}
angleEnd={(Math.PI - (2 * Math.PI) / 3) / 2}
/>
</Chart>
);
3 changes: 2 additions & 1 deletion storybook/stories/goal/15_half_circle.story.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,8 @@ export const Example = () => (
labelMinor=""
centralMajor="280 MB/s"
centralMinor=""
config={{ angleStart: Math.PI, angleEnd: 0 }}
angleStart={Math.PI}
angleEnd={0}
/>
</Chart>
);
3 changes: 2 additions & 1 deletion storybook/stories/goal/16_two_thirds.story.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,8 @@ export const Example = () => (
labelMinor=""
centralMajor="280 MB/s"
centralMinor=""
config={{ angleStart: Math.PI + (Math.PI - (2 * Math.PI) / 3) / 2, angleEnd: -(Math.PI - (2 * Math.PI) / 3) / 2 }}
angleStart={Math.PI + (Math.PI - (2 * Math.PI) / 3) / 2}
angleEnd={-(Math.PI - (2 * Math.PI) / 3) / 2}
/>
</Chart>
);
3 changes: 2 additions & 1 deletion storybook/stories/goal/17_total_circle.story.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,8 @@ export const Example = () => (
labelMinor=""
centralMajor="280 MB/s"
centralMinor=""
config={{ angleStart: Math.PI + Math.PI / 2, angleEnd: -Math.PI / 2 }}
angleStart={Math.PI + Math.PI / 2}
angleEnd={-Math.PI / 2}
/>
</Chart>
);
3 changes: 2 additions & 1 deletion storybook/stories/goal/17_very_small_gap.story.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,8 @@ export const Example = () => (
labelMinor=""
centralMajor="280 MB/s"
centralMinor=""
config={{ angleStart: Math.PI + Math.PI / 2 - Math.PI / 90, angleEnd: -Math.PI / 2 + Math.PI / 90 }}
angleStart={Math.PI + Math.PI / 2 - Math.PI / 90}
angleEnd={-Math.PI / 2 + Math.PI / 90}
/>
</Chart>
);
3 changes: 2 additions & 1 deletion storybook/stories/goal/18_side_gauge.story.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,8 @@ export const Example = () => (
labelMinor=""
centralMajor="280 MB/s"
centralMinor=""
config={{ angleStart: -(Math.PI - (2 * Math.PI) / 3) / 2, angleEnd: (Math.PI - (2 * Math.PI) / 3) / 2 }}
angleStart={-(Math.PI - (2 * Math.PI) / 3) / 2}
angleEnd={(Math.PI - (2 * Math.PI) / 3) / 2}
/>
</Chart>
);
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,8 @@ export const Example = () => (
labelMinor=""
centralMajor="280 MB/s"
centralMinor=""
config={{ angleEnd: -(Math.PI - (2 * Math.PI) / 3) / 2, angleStart: (Math.PI - (2 * Math.PI) / 3) / 2 }}
angleEnd={-(Math.PI - (2 * Math.PI) / 3) / 2}
angleStart={(Math.PI - (2 * Math.PI) / 3) / 2}
/>
</Chart>
);
3 changes: 2 additions & 1 deletion storybook/stories/goal/25_goal_semantic.story.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,8 @@ export const Example = () => {
labelMinor="(thousand USD) "
centralMajor="170"
centralMinor=""
config={{ angleStart: Math.PI, angleEnd: 0 }}
angleStart={Math.PI}
angleEnd={0}
bandLabels={bandLabels}
/>
</Chart>
Expand Down
3 changes: 2 additions & 1 deletion storybook/stories/goal/2_gauge_with_target.story.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,8 @@ export const Example = () => {
labelMinor="(thousand USD) "
centralMajor={`${actual}`}
centralMinor=""
config={{ angleStart, angleEnd }}
angleStart={angleStart}
angleEnd={angleEnd}
/>
</Chart>
);
Expand Down
6 changes: 2 additions & 4 deletions storybook/stories/interactions/17_png_export.story.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -153,10 +153,8 @@ function renderGoalchart() {
labelMinor=""
centralMajor="280 MB/s"
centralMinor=""
config={{
angleStart: Math.PI + (Math.PI - (2 * Math.PI) / 3) / 2,
angleEnd: -(Math.PI - (2 * Math.PI) / 3) / 2,
}}
angleStart={Math.PI + (Math.PI - (2 * Math.PI) / 3) / 2}
angleEnd={-(Math.PI - (2 * Math.PI) / 3) / 2}
/>
);
}
Expand Down