Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

178
Vistas
How to add second array of data to TinyArea graph in antd?

In a React project, a numeric data is plotted which resembles a graph and that data is displayed at specific points when hovered over the graph. Here the numeric data is in array format but, I need to add second array of data to display the corresponding 'dates' to that data. Any appropriate solution?

Below is the code for reference

const DemoTinyArea: React.FC = () => {
  var data = [
    264, 417, 438, 887, 309, 397, 550, 575, 563, 430, 525, 592
  ];
{/* var data2 = [
    '2021-06-01T00:00:00','2021-07-01T00:00:00', '2021-09-01T00:00:00', '2021-02-01T00:00:00', '2021-03-01T00:00:00', '2021-04-01T00:00:00', '2021-07-01T00:00:00', '2021-01-01T00:00:00', '2021-02-01T00:00:00', '2021-05-01T00:00:00', '2021-08-01T00:00:00', '2021-04-01T00:00:00' 
] */}
  var config = {
    height: 60,
    autoFit: false,
    data: data, // How to append data2 here
    smooth: true,
  };
  return <TinyArea {...config} />;
};

As can be seen from above code, an array of data is plotted but, one more array of data is to be appended to show the 'date' data when hovered. Any optimal solution highly appreciated.

This is codesandbox link: https://codesandbox.io/s/gallant-davinci-0hykv?file=/App.tsx

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

The TinyArea component seems to only use a numeric value. If you want to show the corresponding date when hovered you can use a custom tooltip:

import React, { useState, useEffect } from "react";
import { TinyArea } from "@ant-design/charts";

const DemoTinyArea: React.FC = () => {
  var data = [264, 417, 438, 887, 309, 397, 550, 575, 563, 430, 525, 592];
  var data2 = [
    "2021-06-01T00:00:00",
    "2021-07-01T00:00:00",
    "2021-09-01T00:00:00",
    "2021-02-01T00:00:00",
    "2021-03-01T00:00:00",
    "2021-04-01T00:00:00",
    "2021-07-01T00:00:00",
    "2021-01-01T00:00:00",
    "2021-02-01T00:00:00",
    "2021-05-01T00:00:00",
    "2021-08-01T00:00:00",
    "2021-04-01T00:00:00"
  ];
  var config = {
    height: 60,
    autoFit: false,
    data: data,
    tooltip: {
      customContent: (index) => {
        // Format the date
        return <div>{data2[index]}</div>;
      }
    },
    smooth: true
  };
  return <TinyArea {...config} />;
};

export default DemoTinyArea;

You could also consider using another component that can use date for the X-Axis.

about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda