diff --git a/examples/src/components/AreaChartExample.jsx b/examples/src/components/AreaChartExample.jsx index 27e49059f9..953f8f32c5 100644 --- a/examples/src/components/AreaChartExample.jsx +++ b/examples/src/components/AreaChartExample.jsx @@ -1,6 +1,6 @@ // (C) 2007-2018 GoodData Corporation import React, { Component } from 'react'; -import { AreaChart } from '@gooddata/react-components'; +import { AreaChart, BucketApi } from '@gooddata/react-components'; import '@gooddata/react-components/styles/css/main.css'; @@ -26,68 +26,17 @@ export class AreaChartExample extends Component { render() { const measures = [ - { - measure: { - localIdentifier: 'franchiseFeesIdentifier', - definition: { - measureDefinition: { - item: { - identifier: franchiseFeesIdentifier - } - } - }, - format: '#,##0' - } - }, - { - measure: { - localIdentifier: 'franchiseFeesAdRoyaltyIdentifier', - definition: { - measureDefinition: { - item: { - identifier: franchiseFeesAdRoyaltyIdentifier - } - } - }, - format: '#,##0' - } - }, - { - measure: { - localIdentifier: 'franchiseFeesInitialFranchiseFeeIdentifier', - definition: { - measureDefinition: { - item: { - identifier: franchiseFeesInitialFranchiseFeeIdentifier - } - } - }, - format: '#,##0' - } - }, - { - measure: { - localIdentifier: 'franchiseFeesIdentifierOngoingRoyalty', - definition: { - measureDefinition: { - item: { - identifier: franchiseFeesIdentifierOngoingRoyalty - } - } - }, - format: '#,##0' - } - } + BucketApi.measure(franchiseFeesIdentifier) + .format('#,##0'), + BucketApi.measure(franchiseFeesAdRoyaltyIdentifier) + .format('#,##0'), + BucketApi.measure(franchiseFeesInitialFranchiseFeeIdentifier) + .format('#,##0'), + BucketApi.measure(franchiseFeesIdentifierOngoingRoyalty) + .format('#,##0') ]; - const viewBy = { - visualizationAttribute: { - displayForm: { - identifier: monthDateIdentifier - }, - localIdentifier: 'month' - } - }; + const viewBy = BucketApi.visualizationAttribute(monthDateIdentifier); return (
diff --git a/examples/src/components/ArithmeticMeasureChangeExample.jsx b/examples/src/components/ArithmeticMeasureChangeExample.jsx index a99fd571b0..83e3d49b58 100644 --- a/examples/src/components/ArithmeticMeasureChangeExample.jsx +++ b/examples/src/components/ArithmeticMeasureChangeExample.jsx @@ -1,7 +1,7 @@ // (C) 2007-2018 GoodData Corporation import React, { Component } from 'react'; -import { Table } from '@gooddata/react-components'; +import { Table, BucketApi } from '@gooddata/react-components'; import '@gooddata/react-components/styles/css/main.css'; @@ -11,10 +11,6 @@ import { monthDateDataSetAttributeIdentifier, totalSalesIdentifier } from '../utils/fixtures'; -import { - createMeasureBucketItem, - createSamePeriodMeasureBucketItem -} from '../utils/helpers'; export class ArithmeticMeasureChangeExample extends Component { onLoadingChanged(...params) { @@ -28,42 +24,28 @@ export class ArithmeticMeasureChangeExample extends Component { } render() { - const totalSalesYearAgoBucketItem = createSamePeriodMeasureBucketItem( - 'totalSales', monthDateDataSetAttributeIdentifier, '$ Total Sales - year ago' - ); - const totalSalesBucketItem = createMeasureBucketItem( - totalSalesIdentifier, 'totalSales', '$ Total Sales' - ); + const totalSalesYearAgoBucketItem = BucketApi.previousPeriodMeasure( + 'totalSales', [{ dataSet: monthDateDataSetAttributeIdentifier, periodsAgo: 1 }] + ).alias('$ Total Sales - year ago').localIdentifier('totalSales_sp'); + + const totalSalesBucketItem = BucketApi.measure(totalSalesIdentifier) + .localIdentifier('totalSales') + .alias('$ Total Sales'); + const measures = [ totalSalesYearAgoBucketItem, totalSalesBucketItem, - { - measure: { - localIdentifier: 'totalSalesChange', - title: '% Total Sales Change', - definition: { - arithmeticMeasure: { - measureIdentifiers: [ - totalSalesBucketItem.measure.localIdentifier, - totalSalesYearAgoBucketItem.measure.localIdentifier - ], - operator: 'change' - } - }, - format: '#,##0%' - } - } + BucketApi.arithmeticMeasure([ + totalSalesBucketItem.measure.localIdentifier, + totalSalesYearAgoBucketItem.measure.localIdentifier + ], 'change') + .format('#,##0%') + .title('% Total Sales Change') + .localIdentifier('totalSalesChange') ]; const attributes = [ - { - visualizationAttribute: { - displayForm: { - identifier: monthDateIdentifier - }, - localIdentifier: 'month' - } - } + BucketApi.visualizationAttribute(monthDateIdentifier).localIdentifier('month') ]; return ( diff --git a/examples/src/components/ArithmeticMeasureDrillingExample.jsx b/examples/src/components/ArithmeticMeasureDrillingExample.jsx index f1b8f2b6f7..b495710f42 100644 --- a/examples/src/components/ArithmeticMeasureDrillingExample.jsx +++ b/examples/src/components/ArithmeticMeasureDrillingExample.jsx @@ -1,7 +1,7 @@ // (C) 2007-2018 GoodData Corporation import React, { Component } from 'react'; -import { Table, HeaderPredicateFactory } from '@gooddata/react-components'; +import { Table, HeaderPredicateFactory, BucketApi } from '@gooddata/react-components'; import '@gooddata/react-components/styles/css/main.css'; @@ -49,59 +49,23 @@ export class ArithmeticMeasureDrillingExample extends Component { }; const measures = [ - { - measure: { - localIdentifier: localIdentifiers.numberOfRestaurants, - definition: { - measureDefinition: { - item: { - identifier: numberOfRestaurantsIdentifier - } - } - }, - format: '#,##0' - } - }, - { - measure: { - localIdentifier: localIdentifiers.totalSales, - definition: { - measureDefinition: { - item: { - identifier: totalSalesIdentifier - } - } - }, - format: '#,##0' - } - }, - { - measure: { - localIdentifier: 'averageRestaurantSales', - title: '$ Avg Restaurant Sales', - definition: { - arithmeticMeasure: { - measureIdentifiers: [ - localIdentifiers.totalSales, - localIdentifiers.numberOfRestaurants - ], - operator: 'ratio' - } - }, - format: '#,##0' - } - } + BucketApi.measure(numberOfRestaurantsIdentifier) + .localIdentifier(localIdentifiers.numberOfRestaurants) + .format('#,##0'), + BucketApi.measure(totalSalesIdentifier) + .localIdentifier(localIdentifiers.totalSales) + .format('#,##0'), + BucketApi.arithmeticMeasure([ + localIdentifiers.totalSales, + localIdentifiers.numberOfRestaurants + ], 'ratio') + .localIdentifier(localIdentifiers.averageRestaurantSales) + .format('#,##0') + .title('$ Avg Restaurant Sales') ]; const attributes = [ - { - visualizationAttribute: { - displayForm: { - identifier: locationStateDisplayFormIdentifier - }, - localIdentifier: 'month' - } - } + BucketApi.visualizationAttribute(locationStateDisplayFormIdentifier).localIdentifier('month') ]; const drillNotificationComponent = () => { diff --git a/examples/src/components/ArithmeticMeasureMultiplicationExample.jsx b/examples/src/components/ArithmeticMeasureMultiplicationExample.jsx index 2160cfb4fb..eda2454f3a 100644 --- a/examples/src/components/ArithmeticMeasureMultiplicationExample.jsx +++ b/examples/src/components/ArithmeticMeasureMultiplicationExample.jsx @@ -1,7 +1,7 @@ // (C) 2007-2018 GoodData Corporation import React, { Component } from 'react'; -import { Table } from '@gooddata/react-components'; +import { Table, BucketApi } from '@gooddata/react-components'; import '@gooddata/react-components/styles/css/main.css'; @@ -26,63 +26,28 @@ export class ArithmeticMeasureMultiplicationExample extends Component { render() { const localIdentifiers = { numberOfRestaurants: 'numberOfRestaurants', - averageRestaurantDailyCosts: 'averageRestaurantDailyCosts' + averageRestaurantDailyCosts: 'averageRestaurantDailyCosts', + averageStateDailyCosts: 'averageStateDailyCosts' }; const measures = [ - { - measure: { - localIdentifier: localIdentifiers.numberOfRestaurants, - definition: { - measureDefinition: { - item: { - identifier: numberOfRestaurantsIdentifier - } - } - }, - format: '#,##0' - } - }, - { - measure: { - localIdentifier: localIdentifiers.averageRestaurantDailyCosts, - definition: { - measureDefinition: { - item: { - identifier: averageRestaurantDailyCostsIdentifier - } - } - }, - format: '#,##0' - } - }, - { - measure: { - localIdentifier: 'averageStateDailyCosts', - title: '$ Avg State Daily Costs', - definition: { - arithmeticMeasure: { - measureIdentifiers: [ - localIdentifiers.numberOfRestaurants, - localIdentifiers.averageRestaurantDailyCosts - ], - operator: 'multiplication' - } - }, - format: '#,##0' - } - } + BucketApi.measure(numberOfRestaurantsIdentifier) + .localIdentifier(localIdentifiers.numberOfRestaurants) + .format('#,##0'), + BucketApi.measure(averageRestaurantDailyCostsIdentifier) + .localIdentifier(localIdentifiers.averageRestaurantDailyCosts) + .format('#,##0'), + BucketApi.arithmeticMeasure([ + localIdentifiers.numberOfRestaurants, + localIdentifiers.averageRestaurantDailyCosts + ], 'multiplication') + .localIdentifier(localIdentifiers.averageStateDailyCosts) + .format('#,##0') + .title('$ Avg State Daily Costs') ]; const attributes = [ - { - visualizationAttribute: { - displayForm: { - identifier: locationStateDisplayFormIdentifier - }, - localIdentifier: 'month' - } - } + BucketApi.visualizationAttribute(locationStateDisplayFormIdentifier).localIdentifier('month') ]; return ( diff --git a/examples/src/components/ArithmeticMeasureRatioExample.jsx b/examples/src/components/ArithmeticMeasureRatioExample.jsx index 4026169b57..5402f0fa0b 100644 --- a/examples/src/components/ArithmeticMeasureRatioExample.jsx +++ b/examples/src/components/ArithmeticMeasureRatioExample.jsx @@ -1,7 +1,7 @@ // (C) 2007-2018 GoodData Corporation import React, { Component } from 'react'; -import { Table } from '@gooddata/react-components'; +import { Table, BucketApi } from '@gooddata/react-components'; import '@gooddata/react-components/styles/css/main.css'; @@ -26,63 +26,28 @@ export class ArithmeticMeasureRatioExample extends Component { render() { const localIdentifiers = { numberOfRestaurants: 'numberOfRestaurants', - averageRestaurantDailyCosts: 'averageRestaurantDailyCosts' + averageRestaurantDailyCosts: 'averageRestaurantDailyCosts', + averageRestaurantSales: 'averageRestaurantSales' }; const measures = [ - { - measure: { - localIdentifier: localIdentifiers.numberOfRestaurants, - definition: { - measureDefinition: { - item: { - identifier: numberOfRestaurantsIdentifier - } - } - }, - format: '#,##0' - } - }, - { - measure: { - localIdentifier: localIdentifiers.averageRestaurantDailyCosts, - definition: { - measureDefinition: { - item: { - identifier: totalSalesIdentifier - } - } - }, - format: '#,##0' - } - }, - { - measure: { - localIdentifier: 'averageRestaurantSales', - title: '$ Avg Restaurant Sales', - definition: { - arithmeticMeasure: { - measureIdentifiers: [ - localIdentifiers.averageRestaurantDailyCosts, - localIdentifiers.numberOfRestaurants - ], - operator: 'ratio' - } - }, - format: '#,##0' - } - } + BucketApi.measure(numberOfRestaurantsIdentifier) + .localIdentifier(localIdentifiers.numberOfRestaurants) + .format('#,##0'), + BucketApi.measure(totalSalesIdentifier) + .localIdentifier(localIdentifiers.averageRestaurantDailyCosts) + .format('#,##0'), + BucketApi.arithmeticMeasure([ + localIdentifiers.numberOfRestaurants, + localIdentifiers.averageRestaurantDailyCosts + ], 'ratio') + .localIdentifier(localIdentifiers.averageRestaurantSales) + .format('#,##0') + .title('$ Avg State Daily Sales') ]; const attributes = [ - { - visualizationAttribute: { - displayForm: { - identifier: locationStateDisplayFormIdentifier - }, - localIdentifier: 'month' - } - } + BucketApi.visualizationAttribute(locationStateDisplayFormIdentifier).localIdentifier('month') ]; return ( diff --git a/examples/src/components/ArithmeticMeasureSumExample.jsx b/examples/src/components/ArithmeticMeasureSumExample.jsx index 396caf4628..60324d350a 100644 --- a/examples/src/components/ArithmeticMeasureSumExample.jsx +++ b/examples/src/components/ArithmeticMeasureSumExample.jsx @@ -1,7 +1,7 @@ // (C) 2007-2018 GoodData Corporation import React, { Component } from 'react'; -import { Table } from '@gooddata/react-components'; +import { Table, BucketApi } from '@gooddata/react-components'; import '@gooddata/react-components/styles/css/main.css'; @@ -26,79 +26,36 @@ export class ArithmeticMeasureSumExample extends Component { render() { const localIdentifiers = { franchiseFeesAdRoyalty: 'franchiseFeesAdRoyalty', - franchiseFeesOngoingRoyalty: 'franchiseFeesOngoingRoyalty' + franchiseFeesOngoingRoyalty: 'franchiseFeesOngoingRoyalty', + franchiseFeesSum: 'franchiseFeesSum', + franchiseFeesDifference: 'franchiseFeesDifference' }; const measures = [ - { - measure: { - localIdentifier: localIdentifiers.franchiseFeesAdRoyalty, - definition: { - measureDefinition: { - item: { - identifier: franchiseFeesAdRoyaltyIdentifier - } - } - }, - format: '#,##0' - } - }, - { - measure: { - localIdentifier: localIdentifiers.franchiseFeesOngoingRoyalty, - definition: { - measureDefinition: { - item: { - identifier: franchiseFeesIdentifierOngoingRoyalty - } - } - }, - format: '#,##0' - } - }, - { - measure: { - localIdentifier: 'franchiseFeesSum', - title: '$ Ongoing / Ad Royalty Sum', - definition: { - arithmeticMeasure: { - measureIdentifiers: [ - localIdentifiers.franchiseFeesOngoingRoyalty, - localIdentifiers.franchiseFeesAdRoyalty - ], - operator: 'sum' - } - }, - format: '#,##0' - } - }, - { - measure: { - localIdentifier: 'franchiseFeesDifference', - title: '$ Ongoing / Ad Royalty Difference', - definition: { - arithmeticMeasure: { - measureIdentifiers: [ - localIdentifiers.franchiseFeesOngoingRoyalty, - localIdentifiers.franchiseFeesAdRoyalty - ], - operator: 'difference' - } - }, - format: '#,##0' - } - } + BucketApi.measure(franchiseFeesAdRoyaltyIdentifier) + .localIdentifier(localIdentifiers.franchiseFeesAdRoyalty) + .format('#,##0'), + BucketApi.measure(franchiseFeesIdentifierOngoingRoyalty) + .localIdentifier(localIdentifiers.franchiseFeesOngoingRoyalty) + .format('#,##0'), + BucketApi.arithmeticMeasure([ + localIdentifiers.franchiseFeesOngoingRoyalty, + localIdentifiers.franchiseFeesAdRoyalty + ], 'sum') + .localIdentifier(localIdentifiers.franchiseFeesSum) + .format('#,##0') + .title('$ Ongoing / Ad Royalty Sum'), + BucketApi.arithmeticMeasure([ + localIdentifiers.franchiseFeesOngoingRoyalty, + localIdentifiers.franchiseFeesAdRoyalty + ], 'difference') + .localIdentifier(localIdentifiers.franchiseFeesDifference) + .format('#,##0') + .title('$ Ongoing / Ad Royalty Difference') ]; const attributes = [ - { - visualizationAttribute: { - displayForm: { - identifier: locationStateDisplayFormIdentifier - }, - localIdentifier: 'month' - } - } + BucketApi.visualizationAttribute(locationStateDisplayFormIdentifier).localIdentifier('month') ]; return ( diff --git a/examples/src/components/AttributeSortingExample.jsx b/examples/src/components/AttributeSortingExample.jsx index 199f3e48b1..75744238cf 100644 --- a/examples/src/components/AttributeSortingExample.jsx +++ b/examples/src/components/AttributeSortingExample.jsx @@ -1,12 +1,11 @@ // (C) 2007-2018 GoodData Corporation import React, { Component } from 'react'; -import { ColumnChart } from '@gooddata/react-components'; +import { ColumnChart, BucketApi } from '@gooddata/react-components'; import '@gooddata/react-components/styles/css/main.css'; import { totalSalesIdentifier, locationCityDisplayFormIdentifier, projectId } from '../utils/fixtures'; -import { createMeasureBucketItem, createAttributeBucketItem, createAttributeSortItem } from '../utils/helpers'; export class AttributeSortingExample extends Component { render() { @@ -14,9 +13,12 @@ export class AttributeSortingExample extends Component {
); diff --git a/examples/src/components/BarChartDynamicExample.jsx b/examples/src/components/BarChartDynamicExample.jsx index ce52ef91ca..3034104be3 100644 --- a/examples/src/components/BarChartDynamicExample.jsx +++ b/examples/src/components/BarChartDynamicExample.jsx @@ -1,6 +1,6 @@ // (C) 2007-2018 GoodData Corporation import React, { Component } from 'react'; -import { BarChart } from '@gooddata/react-components'; +import { BarChart, BucketApi } from '@gooddata/react-components'; import '@gooddata/react-components/styles/css/main.css'; @@ -47,38 +47,14 @@ export class BarChartDynamicExample extends Component { config } = this.state; - const amount = { - measure: { - localIdentifier: 'amount', - definition: { - measureDefinition: { - item: { - identifier: totalSalesIdentifier - } - } - }, - alias: '$ Total Sales', - format: '#,##0' - } - }; + const amount = BucketApi.measure(totalSalesIdentifier).format('#,##0').alias('$ Total Sales'); - const locationResort = { - visualizationAttribute: { - displayForm: { - identifier: locationResortIdentifier - }, - localIdentifier: 'location_resort' - } - }; + const locationResort = BucketApi.visualizationAttribute(locationResortIdentifier) + .localIdentifier('location_resort'); + + const menuCategory = BucketApi.visualizationAttribute(menuCategoryAttributeDFIdentifier) + .localIdentifier(menuCategoryAttributeDFIdentifier); - const menuCategory = { - visualizationAttribute: { - displayForm: { - identifier: menuCategoryAttributeDFIdentifier - }, - localIdentifier: 'label.menuitem.menucategory' - } - }; return (