cheminfo / cheminfo/common-spectrum
`common-spectrum` could also provide basic `getAnnotations`
- Dominant language
- JavaScript
- Stars
- 3
- Forks
- 2
- PR merge metrics
- No merged PRs in 30d
Description
something basic as
```js
export function getAnnotations(peaks, options = {}) {
const { fillColor = 'green', strokeColor = 'red', creationFct } = options;
if (!peaks) return [];
let annotations = peaks.map((peak) => {
let annotation = {
line: 1,
type: 'rect',
strokeColor: strokeColor,
strokeWidth: 0,
fillColor: fillColor,
};
if (creationFct) {
creationFct(annotation, peak);
}
createAnnotation(annotation, peak, options);
return annotation;
});
return annotations;
}
function createAnnotation(annotation, peak, options = {}) {
const { showAssignment = true, assignmentAngle = -45 } = options;
let labels = [];
let line = 0;
if (showAssignment) {
labels.push({
text: peak.assignment,
size: '18px',
angle: assignmentAngle,
anchor: 'left',
color: 'darkred',
position: {
x: peak.x,
y: peak.y,
dy: `${-15 - line * 14}px`,
},
});
line++;
}
annotation.labels = labels;
annotation.position = [
{
x: peak.x,
y: peak.y,
dy: '-10px',
dx: '-1px',
},
{
x: peak.x,
y: peak.y,
dy: '-5px',
dx: '1px',
},
];
}
```
Contributor guide
No contributing guide indexed for this repository
Research direction
Start by locating the common-spectrum exports and the getAnnotations entry point, then compare the requested behavior with the createAnnotation helper shown in the issue. Add coverage for empty peaks, default colors, assignments, and creationFct customization; done means the basic annotation objects are exposed and the tests pass.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript
- Domain
- data-visualization
- Issue type
- Feature
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 38/100