Skip to content
Draft
Show file tree
Hide file tree
Changes from 3 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
1 change: 1 addition & 0 deletions packages/sanddance-explorer/src/dialogs/settings.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ function filterSignals(signal: NewSignal) {
case SandDance.constants.SignalNames.ColorReverse:
case SandDance.constants.SignalNames.PointScale:
case SandDance.constants.SignalNames.TreeMapMethod:
case SandDance.constants.SignalNames.ScaleNice:
case SandDance.constants.SignalNames.ZGrounded:
return false;
default:
Expand Down
4 changes: 3 additions & 1 deletion packages/sanddance-specs/src/charts/barchartH.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,8 @@ export default function (specContext: SpecContext): SpecBuilderProps {
});
} else {
const aggProps: AggregateContainerProps = {
niceScale: true,
niceScale: { signal: SignalNames.ScaleNice },
niceScaleDisplay: specViewOptions.language.scaleNice,
dock: 'left',
globalAggregateMaxExtentSignal: 'aggMaxExtent',
globalAggregateMaxExtentScaledSignal: 'aggMaxExtentScaled',
Expand Down Expand Up @@ -153,6 +154,7 @@ export default function (specContext: SpecContext): SpecBuilderProps {
specCapabilities: {
countsAndSums: true,
percentage: true,
signals: totalStyle !== 'sum-strip-percent' ? [SignalNames.ScaleNice] : undefined,
roles: [
{
role: 'y',
Expand Down
4 changes: 3 additions & 1 deletion packages/sanddance-specs/src/charts/barchartV.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,8 @@ export default function (specContext: SpecContext): SpecBuilderProps {
});
} else {
const aggProps: AggregateContainerProps = {
niceScale: true,
niceScale: { signal: SignalNames.ScaleNice },
niceScaleDisplay: specViewOptions.language.scaleNice,
dock: 'bottom',
globalAggregateMaxExtentSignal: 'aggMaxExtent',
globalAggregateMaxExtentScaledSignal: 'aggMaxExtentScaled',
Expand Down Expand Up @@ -152,6 +153,7 @@ export default function (specContext: SpecContext): SpecBuilderProps {
specCapabilities: {
countsAndSums: true,
percentage: true,
signals: totalStyle !== 'sum-strip-percent' ? [SignalNames.ScaleNice] : undefined,
roles: [
{
role: 'x',
Expand Down
1 change: 1 addition & 0 deletions packages/sanddance-specs/src/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ export const SignalNames = {
TextSize: 'Text_SizeSignal',
TextTitleSize: 'Text_TitleSizeSignal',
TreeMapMethod: 'Chart_TreeMapMethodSignal',
ScaleNice: 'Chart_ScaleNiceSignal',
XBins: 'RoleX_BinsSignal',
YBins: 'RoleY_BinsSignal',
ZHeight: 'RoleZ_HeightSignal',
Expand Down
25 changes: 21 additions & 4 deletions packages/sanddance-specs/src/layouts/aggregateContainer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
*/

import { Layout, LayoutBuildProps, LayoutProps } from './layout';
import { FieldNames } from '../constants';
import { FieldNames, SignalNames } from '../constants';
import { debounce } from '../defaults';
import { safeFieldName } from '../expr';
import {
AxisScale,
Expand All @@ -20,14 +21,15 @@ import {
} from '../scope';
import { testForCollapseSelection } from '../selection';
import { Column } from '@msrvida/chart-types';
import { JoinAggregateTransform, LinearScale } from 'vega-typings';
import { JoinAggregateTransform, LinearScale, SignalRef } from 'vega-typings';

export interface AggregateContainerProps extends LayoutProps {
dock: 'bottom' | 'top' | 'left';
sumBy: Column;
globalAggregateMaxExtentSignal: string;
globalAggregateMaxExtentScaledSignal: string;
niceScale: boolean;
niceScale: boolean | SignalRef;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@copilot this should be deleted and the nice scale should be added to GlobalScope

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done in commit a9c3182. The niceScale property has been removed from AggregateContainerProps and the signal is now accessed from GlobalScope.signals.scaleNice.

niceScaleDisplay?: string;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@copilot - lets not have this niceScaleDisplay passed through here. Implement this as SignalNames.ZProportion does: see specViewOptions.language.zScaleProportion in packages\sanddance-specs\src\signals.ts

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Implemented globally in textSignals() following the ZProportion pattern in commit cbed0ed. The signal is now created globally and accesses the language string directly from specViewOptions.language.scaleNice without passing through props.

showAxes: boolean;
}

Expand Down Expand Up @@ -69,7 +71,22 @@ export class AggregateContainer extends Layout {

public build(): InnerScope {
const { aggregation, names, props } = this;
const { dock, globalScope, groupings, niceScale, parentScope, showAxes } = props;
const { dock, globalScope, groupings, niceScale, niceScaleDisplay, parentScope, showAxes } = props;

// Add the nice scale signal if display name is provided
if (niceScaleDisplay) {
addSignals(globalScope.scope,
{
name: SignalNames.ScaleNice,
value: true,
bind: {
name: niceScaleDisplay,
debounce,
input: 'checkbox',
},
},
);
}

addTransforms(globalScope.data,
{
Expand Down
5 changes: 5 additions & 0 deletions packages/sanddance-specs/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,11 @@ export interface SpecLanguage {
*/
treeMapMethod: string;

/**
* Label for nice scale toggle.
*/
scaleNice: string;

/**
* Label for scatterPlot point scale slider.
*/
Expand Down
1 change: 1 addition & 0 deletions packages/sanddance/src/defaults.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ export const defaultViewerOptions: ViewerOptions = {
InnerPaddingSize: 'Inner padding size',
OuterPaddingSize: 'Outer padding size',
treeMapMethod: 'Treemap layout',
scaleNice: 'Nice scale',
facetColumns: 'Facet columns',
facetRows: 'Facet rows',
markOpacitySignal: 'Mark opacity',
Expand Down