Skip to content

Commit 43a1a91

Browse files
committed
feature: add ability to move across divisions instead of only within
1 parent ca9251f commit 43a1a91

8 files changed

+278
-101
lines changed

app/static-bundle.js

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

app/testing-bundle.js

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

app/v-bundle.js

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

app/vis.js

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

examples/testing-environment.js

+80-2
Original file line numberDiff line numberDiff line change
@@ -785,6 +785,85 @@ buildGraph(
785785
['any-exit']
786786
);
787787

788+
let stackedStructure = dataNavigator.structure({
789+
data: largerData,
790+
idKey: 'id',
791+
addIds: true,
792+
dimensions: {
793+
values: [
794+
{
795+
dimensionKey: 'date',
796+
type: 'categorical',
797+
behavior: {
798+
extents: 'circular',
799+
childmostNavigation: 'across'
800+
},
801+
operations: {
802+
sortFunction: (a, b, c) => {
803+
if (a.values) {
804+
let aDate = new Date(a.values[Object.keys(a.values)[0]].date);
805+
let bDate = new Date(b.values[Object.keys(b.values)[0]].date);
806+
return aDate - bDate;
807+
} else {
808+
return;
809+
}
810+
}
811+
}
812+
},
813+
{
814+
dimensionKey: 'category',
815+
type: 'categorical',
816+
divisionOptions: {
817+
divisionNodeIds: (dimensionKey, keyValue, i) => {
818+
return createValidId(dimensionKey + keyValue + i);
819+
}
820+
},
821+
behavior: {
822+
extents: 'circular',
823+
childmostNavigation: 'across'
824+
}
825+
}
826+
// {
827+
// dimensionKey: 'value',
828+
// type: 'numerical',
829+
// behavior: {
830+
// extents: 'terminal'
831+
// }
832+
// },
833+
// {
834+
// dimensionKey: 'count',
835+
// type: 'numerical',
836+
// behavior: {
837+
// extents: 'terminal'
838+
// }
839+
// }
840+
]
841+
},
842+
genericEdges: [
843+
{
844+
edgeId: 'any-exit',
845+
edge: {
846+
source: (_d, c) => c,
847+
target: () => {
848+
exit['larger']();
849+
return '';
850+
},
851+
navigationRules: ['exit']
852+
}
853+
}
854+
]
855+
});
856+
console.log('stackedStructure', stackedStructure);
857+
buildGraph(
858+
stackedStructure,
859+
'stacked',
860+
300,
861+
'dimensionLevel',
862+
largerStructure.dimensions[Object.keys(largerStructure.dimensions)[0]].nodeId,
863+
['exit'],
864+
['any-exit']
865+
);
866+
788867
const sparseCategoryTest = [
789868
{
790869
cat: 'meow',
@@ -842,7 +921,6 @@ buildGraph(
842921
['any-exit']
843922
);
844923

845-
846924
let listStructure = dataNavigator.structure({
847925
data: sparseCategoryTest,
848926
idKey: 'catKey',
@@ -857,7 +935,7 @@ let listStructure = dataNavigator.structure({
857935
extents: 'circular'
858936
},
859937
operations: {
860-
compressSparseDivisions: true,
938+
compressSparseDivisions: true
861939
}
862940
}
863941
]

src/data-navigator.ts

+12-1
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ export type DimensionObject = {
9898
dimensionKey: DimensionKey;
9999
divisions: DimensionDivisions;
100100
operations: {
101-
compressSparseDivisions: boolean; // if no division more than 1 child, create 1 division with all children, runs after filtering and sorting
101+
compressSparseDivisions: boolean; // if no division more than 1 child, create 1 division with all children, runs after filtering and sorting
102102
sortFunction?: SortingFunction; // by default sorts numerical in ascending, does not sort categorical
103103
};
104104
behavior?: DimensionBehavior;
@@ -198,6 +198,8 @@ export type DimensionBehavior = {
198198
extents: ExtentType;
199199
customBridgePrevious?: NodeId;
200200
customBridgePost?: NodeId;
201+
childmostNavigation?: ChildmostNavigationStrategy;
202+
childmostMatching?: ChildmostMatchingStrategy;
201203
};
202204

203205
export type Level1Behavior = {
@@ -252,6 +254,13 @@ export type DynamicDimensionRenderId = ((d?: DimensionDatum, a?: GenericDataset)
252254

253255
export type NumericallySubdivide = ((d?: DimensionKey, n?: Nodes) => number) | number;
254256

257+
export type ChildmostMatchingStrategy = (
258+
index?: number,
259+
currentDivisionChild?: DatumObject,
260+
currentDivision?: DivisionObject,
261+
nextDivision?: DivisionObject
262+
) => DatumObject | undefined;
263+
255264
export type AdjustingFunction = (d: Dimensions) => Dimensions;
256265

257266
export type SortingFunction = (a: DatumObject, b: DatumObject, c?: any) => number;
@@ -282,6 +291,8 @@ export type DimensionType = 'numerical' | 'categorical';
282291

283292
export type ExtentType = 'circular' | 'terminal' | 'bridgedCousins' | 'bridgedCustom';
284293

294+
export type ChildmostNavigationStrategy = 'within' | 'across';
295+
285296
export type Level0ExtentType = 'circular' | 'terminal' | 'bridgedCustom';
286297

287298
export type DataType = 'vega-lite' | 'vl' | 'Vega-Lite' | 'generic' | 'default';

0 commit comments

Comments
 (0)