Skip to content

Commit

Permalink
docs: add CPU profile example (opensearch-project#1034)
Browse files Browse the repository at this point in the history
Co-authored-by: Robert Monfera <monfera.robert@gmail.com>
  • Loading branch information
dgieselaar and monfera committed Feb 18, 2021
1 parent 613942f commit 36bc058
Show file tree
Hide file tree
Showing 6 changed files with 57,833 additions and 4 deletions.
4 changes: 1 addition & 3 deletions packages/osd-charts/integration/jest_env_setup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,4 @@ export const toMatchImageSnapshot = configureToMatchImageSnapshot({

expect.extend({ toMatchImageSnapshot });

if (process.env.DEBUG === 'true') {
jest.setTimeout(10 * 60 * 1000); // set timeout to 10 minutes;
}
jest.setTimeout(10 * 1000); // set timeout in milliseconds;
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
57,771 changes: 57,771 additions & 0 deletions packages/osd-charts/src/mocks/hierarchical/cpu_profile_tree_mock.json

Large diffs are not rendered by default.

58 changes: 58 additions & 0 deletions packages/osd-charts/stories/icicle/03_cpu_profile_flame.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
/*
* Licensed to Elasticsearch B.V. under one or more contributor
* license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright
* ownership. Elasticsearch B.V. licenses this file to you under
* the Apache License, Version 2.0 (the "License"); you may
* not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/

import React from 'react';

import { Chart, Datum, Partition, PartitionLayout, PrimitiveValue, Settings } from '../../src';
import data from '../../src/mocks/hierarchical/cpu_profile_tree_mock.json';
import { STORYBOOK_LIGHT_THEME } from '../shared';
import { config } from '../utils/hierarchical_input_utils';
import { discreteColor, viridis18 as palette } from '../utils/utils';

const color = palette.slice().reverse();

const getLayerSpec = (maxDepth: number = 30) =>
[...new Array(maxDepth + 1)].map((_, depth) => ({
groupByRollup: (d: Datum) => d.layers[depth],
nodeLabel: (d: PrimitiveValue) => String(d),
showAccessor: (d: PrimitiveValue) => d !== undefined,
shape: {
fillColor: () => discreteColor(color, 0.8)(depth),
},
}));

export const Example = () => {
return (
<Chart className="story-chart">
<Settings theme={STORYBOOK_LIGHT_THEME} />
<Partition
id="spec_1"
data={data}
valueAccessor={(d: Datum) => d.value as number}
valueFormatter={() => ''}
layers={getLayerSpec()}
config={{
...config,
partitionLayout: PartitionLayout.icicle,
drilldown: true,
}}
/>
</Chart>
);
};
1 change: 1 addition & 0 deletions packages/osd-charts/stories/icicle/icicle.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,5 +26,6 @@ export default {
},
};

export { Example as cpuProfileFlameChart } from './03_cpu_profile_flame';
export { Example as flameChart } from './02_unix_flame';
export { Example as icicleChart } from './01_unix_icicle';
3 changes: 2 additions & 1 deletion packages/osd-charts/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
"skipLibCheck": true,
"downlevelIteration": true,
"typeRoots": ["./node_modules/@types/", "./global.d.ts"],
"stripInternal": true
"stripInternal": true,
"resolveJsonModule": true
}
}

0 comments on commit 36bc058

Please sign in to comment.