import React from 'react';
import ProjectActivityGraphsHeader from './ProjectActivityGraphsHeader';
import StaticGraphs from './StaticGraphs';
+import { GRAPHS_METRICS_STYLE } from '../utils';
import type { RawQuery } from '../../../helpers/query';
import type { Analysis, MeasureHistory, Query } from '../types';
measuresHistory={props.measuresHistory}
metricsType={props.metricsType}
project={props.project}
+ seriesStyle={GRAPHS_METRICS_STYLE[graph]}
showAreas={['coverage', 'duplications'].includes(graph)}
/>
</div>
leakPeriodDate: Date,
loading: boolean,
measuresHistory: Array<MeasureHistory>,
- metricsType: string
+ metricsType: string,
+ seriesStyle?: { [string]: string }
};
export default class StaticGraphs extends React.PureComponent {
getSeries = () =>
sortBy(
- this.props.measuresHistory.map(measure => {
+ this.props.measuresHistory.map((measure, idx) => {
if (measure.metric === 'uncovered_lines') {
return generateCoveredLinesMetric(measure, this.props.measuresHistory);
}
return {
name: measure.metric,
translatedName: translate('metric', measure.metric, 'name'),
+ style: this.props.seriesStyle ? this.props.seriesStyle[measure.metric] : idx,
data: measure.history.map(analysis => ({
x: analysis.date,
y: this.props.metricsType === 'LEVEL' ? analysis.value : Number(analysis.value)
import ChartLegendIcon from '../../../components/icons-components/ChartLegendIcon';
type Props = {
- series: Array<{ name: string, translatedName: string }>
+ series: Array<{ name: string, translatedName: string, style: string }>
};
export default function StaticGraphsLegend({ series }: Props) {
return (
<div className="project-activity-graph-legends">
- {series.map((serie, idx) => (
+ {series.map(serie => (
<span className="big-spacer-left big-spacer-right" key={serie.name}>
<ChartLegendIcon
- className={classNames('spacer-right line-chart-legend', 'line-chart-legend-' + idx)}
+ className={classNames(
+ 'spacer-right line-chart-legend',
+ 'line-chart-legend-' + serie.style
+ )}
/>
{serie.translatedName}
</span>
overview: ['bugs', 'vulnerabilities', 'code_smells'],
coverage: ['uncovered_lines', 'lines_to_cover'],
duplications: ['duplicated_lines', 'ncloc'],
- remediation: ['sqale_index', 'security_remediation_effort', 'reliability_remediation_effort']
+ remediation: ['reliability_remediation_effort', 'security_remediation_effort', 'sqale_index']
+};
+export const GRAPHS_METRICS_STYLE = {
+ overview: { bugs: '0', code_smells: '1', vulnerabilities: '2' },
+ coverage: {
+ lines_to_cover: '1',
+ uncovered_lines: '0'
+ },
+ duplications: {
+ duplicated_lines: '0',
+ ncloc: '1'
+ },
+ remediation: {
+ reliability_remediation_effort: '0',
+ security_remediation_effort: '2',
+ sqale_index: '1'
+ }
};
const parseGraph = (value?: string): string => {
type Point = { x: Date, y: number | string };
-type Serie = { name: string, data: Array<Point> };
+type Serie = { name: string, data: Array<Point>, style: string };
type Event = { className?: string, name: string, date: Date };
{this.props.series.map((serie, idx) => (
<path
key={`${idx}-${serie.name}`}
- className={classNames('line-chart-path', 'line-chart-path-' + idx)}
+ className={classNames('line-chart-path', 'line-chart-path-' + serie.style)}
d={lineGenerator(serie.data)}
/>
))}
{this.props.series.map((serie, idx) => (
<path
key={`${idx}-${serie.name}`}
- className={classNames('line-chart-area', 'line-chart-area-' + idx)}
+ className={classNames('line-chart-area', 'line-chart-area-' + serie.style)}
d={areaGenerator(serie.data)}
/>
))}