# Labels

const config = {
  type: 'treemap',
  data: {
    datasets: [
      {
        label: 'My First dataset',
        tree: Utils.numbers(NUMBER_CFG),
        borderColor: 'red',
        borderWidth: 0.5,
        spacing: 0,
        backgroundColor: (ctx) => colorFromRaw(ctx),
        labels: {
          align: 'left',
          display: true,
          formatter(ctx) {
            if (ctx.type !== 'data') {
              return;
            }
            return INTL_NUM_FORMAT.format(ctx.raw.v);
          },
          color: 'black',
          font: {
            size: 16,
          },
          hoverFont: {
            size: 24,
            weight: 'bold'
          },
          position: 'center'
        }
      }
    ],
  },
  options: {
    plugins: {
      title: {
        display: true,
        text: 'Labelling data'
      },
      legend: {
        display: false
      }
    }
  }
};
Last Updated: 11/13/2023, 6:13:46 PM