Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
array.forEach(d => {
const key = accessor(d);
if (key) {
names[key] = true;
}
});
// sort to make color assignment deterministic
const sortedNames = Object.keys(names).sort();
if (sortedNames.length > colors.categories.length) {
console.warn(
`Unique color values ${sortedNames.length} exceeds the number of unique colors
(${colors.categories.length}). Consider filtering event types.`,
);
}
return scaleOrdinal({
range: [`url(#${FILTERED_EVENTS})`, ...colors.categories],
domain: [FILTERED_EVENTS, ...sortedNames],
});
}
const BUMPS_PER_LAYER = 10;
const keys = range(NUM_LAYERS);
// scales
const yScale = scaleLinear({
domain: [-30, 50],
});
const xScale = scaleLinear({
domain: [0, SAMPLES_PER_LAYER - 1],
});
const colorScale = scaleOrdinal({
domain: keys,
range: ['#ffc409', '#f14702', '#262d97', 'white', '#036ecd', '#9ecadd', '#51666e'],
});
const patternScale = scaleOrdinal({
domain: keys,
range: ['mustard', 'cherry', 'navy', 'circles', 'circles', 'circles', 'circles'],
});
export default class Streamgraph extends React.Component {
render() {
const { width, height } = this.props;
if (width < 10) return null;
const layers = transpose(keys.map(() => bumps(SAMPLES_PER_LAYER, BUMPS_PER_LAYER)));
xScale.range([0, width]);
yScale.range([height, 0]);
return (
<svg height="{height}" width="{width}"></svg>
const xMax = width - margin.left - margin.right;
const yMax = height - margin.top - margin.bottom;
// // scales
const xScale = scaleLinear({
rangeRound: [0, xMax],
domain: [0, max(totals)],
nice: true
});
const yScale = scaleBand({
rangeRound: [yMax, 0],
domain: data.map(y),
padding: 0.2,
tickFormat: () => val => formatDate(val)
});
const zScale = scaleOrdinal({
domain: keys,
range: ['#6c5efb', '#c998ff', '#a44afe']
});
let tooltipTimeout;
return (
<div style="{{">
<svg height="{height}" width="{width}">
<rect rx="{14}" fill="#eaedff" height="{height}" width="{width}" y="{0}" x="{0}"></rect>
</svg></div>
const quantileScale = scaleQuantize({
domain: [0, 0.15],
range: ['#eb4d70', '#f19938', '#6ce18b', '#78f6ef', '#9096f8'],
});
const linearScale = scaleLinear({
domain: [0, 10],
range: ['#ed4fbb', '#e9a039'],
});
const thresholdScale = scaleThreshold({
domain: [0.01, 0.02, 0.04, 0.06, 0.08, 0.1],
range: ['#f2f0f7', '#dadaeb', '#bcbddc', '#9e9ac8', '#756bb1', '#54278f'],
});
const ordinalColorScale = scaleOrdinal({
domain: ['a', 'b', 'c', 'd'],
range: ['#66d981', '#71f5ef', '#4899f1', '#7d81f6'],
});
const ordinalColor2Scale = scaleOrdinal({
domain: ['a', 'b', 'c', 'd'],
range: ['#fae856', '#f29b38', '#e64357', '#8386f7'],
});
const shapeScale = scaleOrdinal({
domain: ['a', 'b', 'c', 'd', 'e'],
range: [
,
,
,
,
rangeRound: [0, y0Scale.bandwidth()],
domain: keys,
padding: 0.1
});
const xScale = scaleLinear({
rangeRound: [xMax, 0],
domain: [
0,
max(data, d => {
return max(keys, key => d[key]);
})
]
});
const zScale = scaleOrdinal({
domain: keys,
range: ['#aeeef8', '#e5fd3d', '#9caff6']
});
return (
<svg height="{height}" width="{width}">
<rect rx="{14}" fill="#612efb" height="{height}" width="{width}" y="{0}" x="{0}"></rect>
</svg>
constructor(props) {
super(props);
this.state = {
items: genItems({ ...props })
};
this.colorScale = scaleOrdinal({
range: colors,
domain: this.state.items.map(d => d.id)
});
}
export default ({
data = [],
width = 500,
height = 500,
margin = { top: 50, right: 50, bottom: 50, left: 50 },
chartType,
innerRadius = 0
}) => {
const filteredList = data.filter(i => i !== undefined);
if (filteredList.length === 0) {
return null;
}
const total = filteredList.reduce(
(acc, value) => (acc.value ? acc.value + value.value : acc + value.value)
);
const colorScale = scaleOrdinal({ range: chartTheme.colors.categories });
return (
<div>
(
<div>
<strong>{datum.label}</strong> ({datum.value})
</div>
)}
>
d.value}</div>
});
const x1Scale = scaleBand({
rangeRound: [0, x0Scale.bandwidth()],
domain: keys,
padding: 0.1
});
const yScale = scaleLinear({
rangeRound: [yMax, 0],
domain: [
0,
max(data, d => {
return max(keys, key => d[key]);
})
]
});
const zScale = scaleOrdinal({
domain: keys,
range: ['#aeeef8', '#e5fd3d', '#9caff6']
});
return (
<svg height="{height}" width="{width}">
<rect rx="{14}" fill="{`#612efb`}" height="{height}" width="{width}" y="{0}" x="{0}"></rect>
</svg>
const thresholdScale = scaleThreshold({
domain: [0.01, 0.02, 0.04, 0.06, 0.08, 0.1],
range: ['#f2f0f7', '#dadaeb', '#bcbddc', '#9e9ac8', '#756bb1', '#54278f'],
});
const ordinalColorScale = scaleOrdinal({
domain: ['a', 'b', 'c', 'd'],
range: ['#66d981', '#71f5ef', '#4899f1', '#7d81f6'],
});
const ordinalColor2Scale = scaleOrdinal({
domain: ['a', 'b', 'c', 'd'],
range: ['#fae856', '#f29b38', '#e64357', '#8386f7'],
});
const shapeScale = scaleOrdinal({
domain: ['a', 'b', 'c', 'd', 'e'],
range: [
,
,
,
,
() => (
),
],
});
export default ({ width }) => {
if (width < 10) return null;
export function singleHueScaleFactory(hue) {
return scaleOrdinal({ range: [...(allColors[hue] || grayColors)].reverse() });
}