-
Notifications
You must be signed in to change notification settings - Fork 120
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
154 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 1 addition & 3 deletions
4
src/chart_types/partition_chart/layout/viewmodel/link_text_layout.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
import { Chart, Datum, Partition, PartitionLayout } from '../../src'; | ||
import { mocks } from '../../src/mocks/hierarchical/index'; | ||
import React from 'react'; | ||
import { ShapeTreeNode } from '../../src/chart_types/partition_chart/layout/types/viewmodel_types'; | ||
import { | ||
categoricalFillColor, | ||
colorBrewerCategoricalStark9, | ||
countryLookup, | ||
productLookup, | ||
regionLookup, | ||
} from '../utils/utils'; | ||
|
||
export const example = () => ( | ||
<Chart className="story-chart"> | ||
<Partition | ||
id="spec_26" | ||
data={mocks.miniSunburst} | ||
valueAccessor={(d: Datum) => d.exportVal as number} | ||
valueGetter="percent" | ||
valueFormatter={(d: number) => `${Math.round(d)}%`} | ||
layers={[ | ||
{ | ||
groupByRollup: (d: Datum) => d.sitc1, | ||
nodeLabel: (d: any) => productLookup[d].name, | ||
shape: { | ||
fillColor: (d: ShapeTreeNode) => { | ||
return categoricalFillColor(colorBrewerCategoricalStark9, 0.7)(d.sortIndex); | ||
}, | ||
}, | ||
}, | ||
{ | ||
groupByRollup: (d: Datum) => countryLookup[d.dest].continentCountry.substr(0, 2), | ||
nodeLabel: (d: any) => regionLookup[d].regionName, | ||
shape: { | ||
fillColor: (d: ShapeTreeNode) => { | ||
return categoricalFillColor(colorBrewerCategoricalStark9, 0.5)(d.parent.sortIndex); | ||
}, | ||
}, | ||
}, | ||
{ | ||
groupByRollup: (d: Datum) => d.dest, | ||
nodeLabel: (d: any) => countryLookup[d].name, | ||
shape: { | ||
fillColor: (d: ShapeTreeNode) => { | ||
return categoricalFillColor(colorBrewerCategoricalStark9, 0.3)(d.parent.parent.sortIndex); | ||
}, | ||
}, | ||
}, | ||
]} | ||
config={{ | ||
partitionLayout: PartitionLayout.sunburst, | ||
linkLabel: { | ||
maxCount: 0, | ||
fontSize: 14, | ||
}, | ||
fontFamily: 'Arial', | ||
fillLabel: { | ||
fontStyle: 'italic', | ||
textInvertible: true, | ||
fontWeight: 900, | ||
valueFont: { | ||
fontFamily: 'Menlo', | ||
fontStyle: 'normal', | ||
fontWeight: 100, | ||
}, | ||
}, | ||
margin: { top: 0, bottom: 0, left: 0, right: 0 }, | ||
minFontSize: 1, | ||
idealFontSizeJump: 1.1, | ||
outerSizeRatio: 1, | ||
emptySizeRatio: 0, | ||
circlePadding: 4, | ||
backgroundColor: 'rgba(229,229,229,1)', | ||
}} | ||
/> | ||
</Chart> | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
import { Chart, Datum, Partition, PartitionLayout } from '../../src'; | ||
import { mocks } from '../../src/mocks/hierarchical/index'; | ||
import { percentValueGetter } from '../../src/chart_types/partition_chart/layout/config/config'; | ||
import { arrayToLookup, hueInterpolator } from '../../src/chart_types/partition_chart/layout/utils/calcs'; | ||
import { countryDimension, regionDimension } from '../../src/mocks/hierarchical/dimension_codes'; | ||
import { palettes } from '../../src/mocks/hierarchical/palettes'; | ||
import React from 'react'; | ||
import { ShapeTreeNode } from '../../src/chart_types/partition_chart/layout/types/viewmodel_types'; | ||
|
||
const regionLookup = arrayToLookup((d: Datum) => d.region, regionDimension); | ||
const countryLookup = arrayToLookup((d: Datum) => d.country, countryDimension); | ||
|
||
const interpolatorTurbo = hueInterpolator(palettes.turbo.map(([r, g, b]) => [r, g, b, 0.7])); | ||
|
||
export const example = () => ( | ||
<Chart | ||
className="story-chart" | ||
size={ | ||
{ | ||
/*height: 800*/ | ||
} | ||
} | ||
> | ||
<Partition | ||
id="spec_7" | ||
data={mocks.sunburst} | ||
valueAccessor={(d: Datum) => d.exportVal as number} | ||
valueGetter={percentValueGetter} | ||
valueFormatter={(d: number) => `${Math.round(d)}%`} | ||
layers={[ | ||
{ | ||
groupByRollup: (d: Datum) => countryLookup[d.dest].continentCountry.substr(0, 2), | ||
nodeLabel: (d: any) => regionLookup[d].regionName, | ||
fillLabel: { | ||
fontFamily: 'Phosphate-Inline', | ||
textColor: 'yellow', | ||
textInvertible: false, | ||
}, | ||
shape: { fillColor: 'rgba(0,0,0,0)' }, | ||
}, | ||
{ | ||
groupByRollup: (d: Datum) => d.dest, | ||
nodeLabel: (d: any) => countryLookup[d].name, | ||
fillLabel: { | ||
textColor: 'black', | ||
textInvertible: false, | ||
fontWeight: 200, | ||
fontStyle: 'normal', | ||
fontFamily: 'Helvetica', | ||
fontVariant: 'small-caps', | ||
valueFont: { fontWeight: 400, fontStyle: 'italic' }, | ||
}, | ||
shape: { | ||
fillColor: (d: ShapeTreeNode) => { | ||
// primarily, pick color based on parent's index, but then perturb by the index within the parent | ||
return interpolatorTurbo( | ||
(d.parent.sortIndex + d.sortIndex / d.parent.children.length) / (d.parent.parent.children.length + 1), | ||
); | ||
}, | ||
}, | ||
}, | ||
]} | ||
config={{ | ||
partitionLayout: PartitionLayout.treemap, | ||
margin: { top: 0, bottom: 0, left: 0, right: 0 }, | ||
minFontSize: 4, | ||
maxFontSize: 84, | ||
idealFontSizeJump: 1.15, | ||
outerSizeRatio: 1, | ||
}} | ||
/> | ||
</Chart> | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters