el / canvas-table

Fast table implementation in Canvas
MIT License
68 stars 14 forks source link

Request to customize spacing between columns #10

Closed jasperchua99 closed 2 years ago

jasperchua99 commented 2 years ago

Hi, i am wondering if its possible for you to create an option that allows me to limit the size of my individual columns, like my column 1 i want it to be shorter then column 2

image

el commented 2 years ago

Can you share your config?

jasperchua99 commented 2 years ago
rectX = 30;
rectY = 420;
rectWidth = 415;
rectHeight = 140;
config = {
    columns: [
      {title: "Type",
        options: { 
          textAlign: "left" }},
      {title: "Efficiency",
        options: { 
          textAlign: "left"
        }},
      {title: "Max",
        options: { textAlign: "right" }}
  ],
    data: datas2,
    options:  {
      background: 'transparent',
      fit: true,
      subtitle: {
        color: "white",
        fontSize: 5,
      padding: 1

      },
      header: {
        color: "white",
        fontSize: 7,
      padding: 1

      },
      cell: {
        color: "white",
        fontSize: 9,
      padding: 2

      },
      devicePixelRatio: 2,
      padding: 1

    }
    };

  const canvas3 = Canvas.createCanvas(rectWidth / 2, rectHeight / 2);
  const ct3 = new CanvasTable(canvas3, config);
  await ct3.generateTable();
  let tab3 = await Canvas.loadImage(await ct3.renderToBuffer());
el commented 2 years ago

https://github.com/el/canvas-table/commit/4151c6bb1a0fe2bb489241ed918d0ee7f4dd7222 You should be able use the new minWidth and maxWidth in the column options with the v0.1.0