# 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/25/2024, 4:10:50 PM