recharts#XAxisProps TypeScript Examples

The following examples show how to use recharts#XAxisProps. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: Question.tsx    From project-loved-web with MIT License 5 votes vote down vote up
function ComparingChart({ answers, comparingStatistic }: ComparingChartProps) {
  const intl = useIntl();
  const colors = useColors();

  const xAxisProps: XAxisProps = {
    dataKey: 'statistic',
    interval: 'preserveStartEnd',
    stroke: colors.content,
    tick: { fill: colors.content },
    tickLine: { stroke: colors.content },
  };

  if (comparingStatistic === 'rank') {
    xAxisProps.domain = ['dataMin', 'dataMax'];
    xAxisProps.scale = 'log';
    xAxisProps.tickFormatter = (value) => intl.formatNumber(value);
    xAxisProps.type = 'number';
  }

  return (
    <AreaChart data={answers} width={700} height={175}>
      <defs>
        <linearGradient id='answerColor' x1='0' y1='0' x2='0' y2='1'>
          <stop offset='0%' stopColor={colors['rating-2']} stopOpacity={0.9} />
          <stop offset='20%' stopColor={colors['rating-1']} stopOpacity={0.8} />
          <stop offset='40%' stopColor={colors['rating-0']} stopOpacity={0.7} />
          <stop offset='60%' stopColor={colors['rating--1']} stopOpacity={0.6} />
          <stop offset='80%' stopColor={colors['rating--2']} stopOpacity={0.5} />
          <stop offset='100%' stopColor={colors['rating--2']} stopOpacity={0} />
        </linearGradient>
      </defs>
      <XAxis {...xAxisProps} />
      <YAxis dataKey='average' domain={[0, 5]} hide />
      <Area
        type='monotone'
        dataKey='average'
        stroke={colors.content}
        fillOpacity={1}
        fill='url(#answerColor)'
      />
    </AreaChart>
  );
}