Files
weave-scope/client/app/scripts/charts/node-shape-circle.js
Simon Howe a104962aa2 Simple metric selection clicking!
Locks onto a metric after you mouseout.
2016-04-04 17:48:40 +02:00

31 lines
1.0 KiB
JavaScript

import React from 'react';
import {getMetricValue} from '../utils/data-utils.js';
export default function NodeShapeCircle({highlighted, size, color, metric}) {
const hightlightNode = <circle r={size * 0.7} className="highlighted" />;
const clipId = `mask-${Math.random()}`;
const {height, formattedValue} = getMetricValue(metric, size);
return (
<g className="shape">
<defs>
<clipPath id={clipId}>
<rect
width={size}
height={size}
x={-size * 0.5}
y={size * 0.5 - height}
/>
</clipPath>
</defs>
{highlighted && hightlightNode}
<circle r={size * 0.5} className="border" stroke={color} />
<circle r={size * 0.45} className="shadow" />
<circle r={size * 0.45} className="metric-fill" clipPath={`url(#${clipId})`} />
{highlighted ?
<text dy="0.35em" style={{'textAnchor': 'middle'}}>{formattedValue}</text> :
<circle className="node" r={Math.max(2, (size * 0.125))} />}
</g>
);
}