Skip to content

Commit

Permalink
fix(ui): fix demo folder
Browse files Browse the repository at this point in the history
  • Loading branch information
imtuanpham committed May 9, 2024
1 parent 4ce5ed4 commit b9aa81a
Show file tree
Hide file tree
Showing 3 changed files with 198 additions and 0 deletions.
43 changes: 43 additions & 0 deletions packages/sdk-ui/src/__demo__/example-data.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
export const exampleData = {
data: {
columns: [
{ name: 'Years', type: 'date' },
{ name: 'Group', type: 'string' },
{ name: 'Quantity', type: 'number' },
{ name: 'Units', type: 'number' },
{ name: 'Returns', type: 'number' },
],
rows: [
['2009', 'A', 6781, 1000, 558],
['2009', 'B', 5500, 1500, 440],
['2010', 'A', 4471, 7000, 557],
['2011', 'B', 1812, 5000, 151],
['2012', 'B', 5001, 6000, 440],
['2013', 'A', 2045, 4000, 304],
['2014', 'B', 3010, 9000, 341],
['2015', 'A', 5447, 8000, 444],
['2016', 'B', 4242, 7000, 384],
['2017', 'B', 936, 2000, 73],
],
},
years: {
name: 'Years',
type: 'date',
},
group: {
name: 'Group',
type: 'string',
},
quantity: {
name: 'Quantity',
aggregation: 'sum',
},
units: {
name: 'Units',
aggregation: 'sum',
},
returns: {
name: 'Returns',
aggregation: 'sum',
},
};
141 changes: 141 additions & 0 deletions packages/sdk-ui/src/__demo__/sample-ecommerce-autogenerated.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,141 @@
import {
Dimension,
DateDimension,
Attribute,
createAttribute,
createDateDimension,
createDimension,
} from '@sisense/sdk-data';

export const DataSource = 'Sample ECommerce';

interface BrandDimension extends Dimension {
Brand: Attribute;
BrandID: Attribute;
}
export const Brand = createDimension({
name: 'Brand',
Brand: createAttribute({
name: 'Brand',
type: 'text-attribute',
expression: '[Brand.Brand]',
}),
BrandID: createAttribute({
name: 'BrandID',
type: 'numeric-attribute',
expression: '[Brand.Brand ID]',
}),
}) as BrandDimension;

interface CategoryDimension extends Dimension {
Category: Attribute;
CategoryID: Attribute;
}
export const Category = createDimension({
name: 'Category',
Category: createAttribute({
name: 'Category',
type: 'text-attribute',
expression: '[Category.Category]',
}),
CategoryID: createAttribute({
name: 'CategoryID',
type: 'numeric-attribute',
expression: '[Category.Category ID]',
}),
}) as CategoryDimension;

interface CommerceDimension extends Dimension {
AgeRange: Attribute;
BrandID: Attribute;
CategoryID: Attribute;
Condition: Attribute;
Cost: Attribute;
CountryID: Attribute;
DateMonth: Attribute;
Gender: Attribute;
Quantity: Attribute;
Revenue: Attribute;
VisitID: Attribute;
Date: DateDimension;
}
export const Commerce = createDimension({
name: 'Commerce',
AgeRange: createAttribute({
name: 'AgeRange',
type: 'text-attribute',
expression: '[Commerce.Age Range]',
}),
BrandID: createAttribute({
name: 'BrandID',
type: 'numeric-attribute',
expression: '[Commerce.Brand ID]',
}),
CategoryID: createAttribute({
name: 'CategoryID',
type: 'numeric-attribute',
expression: '[Commerce.Category ID]',
}),
Condition: createAttribute({
name: 'Condition',
type: 'text-attribute',
expression: '[Commerce.Condition]',
}),
Cost: createAttribute({
name: 'Cost',
type: 'numeric-attribute',
expression: '[Commerce.Cost]',
}),
CountryID: createAttribute({
name: 'CountryID',
type: 'numeric-attribute',
expression: '[Commerce.Country ID]',
}),
DateMonth: createAttribute({
name: 'DateMonth',
type: 'numeric-attribute',
expression: '[Commerce.Date (Month)]',
}),
Gender: createAttribute({
name: 'Gender',
type: 'text-attribute',
expression: '[Commerce.Gender]',
}),
Quantity: createAttribute({
name: 'Quantity',
type: 'numeric-attribute',
expression: '[Commerce.Quantity]',
}),
Revenue: createAttribute({
name: 'Revenue',
type: 'numeric-attribute',
expression: '[Commerce.Revenue]',
}),
VisitID: createAttribute({
name: 'VisitID',
type: 'numeric-attribute',
expression: '[Commerce.Visit ID]',
}),
Date: createDateDimension({
name: 'Date',
expression: '[Commerce.Date (Calendar)]',
}),
}) as CommerceDimension;

interface CountryDimension extends Dimension {
Country: Attribute;
CountryID: Attribute;
}
export const Country = createDimension({
name: 'Country',
Country: createAttribute({
name: 'Country',
type: 'text-attribute',
expression: '[Country.Country]',
}),
CountryID: createAttribute({
name: 'CountryID',
type: 'numeric-attribute',
expression: '[Country.Country ID]',
}),
}) as CountryDimension;
14 changes: 14 additions & 0 deletions packages/sdk-ui/src/__demo__/sample-ecommerce.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import { measureFactory } from '@sisense/sdk-data';

import { Commerce, Brand, Country, Category, DataSource } from './sample-ecommerce-autogenerated';

export { Commerce, Brand, Category, Country, DataSource };

/** adding predefined set of measures */
export const Measures = {
SumCost: measureFactory.sum(Commerce.Cost).format('0,0$'),
AvgCost: measureFactory.average(Commerce.Cost).format('0,0$'),
SumRevenue: measureFactory.sum(Commerce.Revenue, 'Total Revenue').format('0,0$'),
Quantity: measureFactory.sum(Commerce.Quantity, 'Total Quantity').format('0,0'),
CountBrands: measureFactory.countDistinct(Commerce.BrandID).format('0,0'),
};

0 comments on commit b9aa81a

Please sign in to comment.