All files / modules/75-cf/components/FlagActivation/views EvaluationsChart.tsx

100% Statements 10/10
100% Branches 0/0
100% Functions 2/2
100% Lines 9/9

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86              3x 3x 3x 3x   3x                                                                                                                           3x         2x 2x     2x    
/*
 * Copyright 2021 Harness Inc. All rights reserved.
 * Use of this source code is governed by the PolyForm Shield 1.0.0 license
 * that can be found in the licenses directory at the root of this repository, also available at
 * https://polyformproject.org/wp-content/uploads/2020/06/PolyForm-Shield-1.0.0.txt.
 */
 
import React, { useMemo } from 'react'
import HighchartsReact from 'highcharts-react-official'
import Highcharts, { PlotOptions } from 'highcharts'
import { clone, merge } from 'lodash-es'
 
const chartDefaultOptions: Highcharts.Options = {
  chart: {
    type: 'column'
  },
  legend: {
    layout: 'vertical',
    align: 'left',
    verticalAlign: 'top',
    x: 80,
    y: 40,
    floating: true,
    borderWidth: 1
  },
  xAxis: {
    crosshair: {
      width: 2,
      dashStyle: 'ShortDash',
      color: '#0092E4',
      zIndex: 10
    },
    tickmarkPlacement: 'on',
    startOnTick: true,
    plotLines: [
      {
        value: -1,
        width: 1,
        color: '#D9DAE5',
        zIndex: 10
      }
    ]
  },
  yAxis: {
    title: undefined,
    gridLineColor: 'transparent'
  },
  tooltip: {
    // shared: true,
    useHTML: true
    // Custom tooltip will be implemented with https://harness.atlassian.net/browse/FFM-802
    // formatter: function formatter(): string {
    //   const th = this as any // eslint-disable-line
    //   return th.points[0]?.point?.series?.userOptions?.tooltips?.[th.x]
    // },
    // hideDelay: 1500,
    // style: {
    //   pointerEvents: 'auto'
    // }
  },
  credits: {
    enabled: false
  },
  plotOptions: {
    column: {
      stacking: 'normal',
      dataLabels: {
        enabled: false
      },
      borderColor: undefined
    }
  }
}
 
export const EvaluationsChart: React.FC<{ series: PlotOptions; categories: string[]; title: string }> = ({
  series,
  categories,
  title
}) => {
  const parsedOptions = useMemo(
    () => merge(clone(chartDefaultOptions), { title: { text: title }, series, xAxis: { categories } }),
    [series, categories, title]
  )
  return <HighchartsReact highcharts={Highcharts} options={parsedOptions} />
}