简体   繁体   中英

antV chart design legend

please I want to make legend in this chart based on the 'action' value. I just got 'sell' for the both lines: enter image description here The code:

  const config = {
    data,
    xField: 'createdAt',
    yField: 'price',
    seriesField: 'action',
    yAxis: {
      label: {

        formatter: (v) => `${v}`.replace(/\d{1,3}(?=(\d{3})+$)/g, (s) => `${s},`),
      },
    },
    
    legend: {
      position: 'top-right',
      itemName: {
        style: {
          fill: '#000',
        },

        formatter: (seriesField) => {
          if (seriesField.value === "1") {
            return 'buy';
          }

          return 'sell';

        },
        //formatter: (name) => name,

      },
    },


  };

I think you just need legend: true inside your config

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM