Skip to content

Data Layout ​

What is iDraw.js's Data Layout ​

iDraw.js handles the layout rendering of drawing content, primarily providing an overall background layout and container for the content. This includes elements such as the coordinate origin point, length, width, and background color of the content canvas, as well as whether overflow hidden is enabled for content.

Layout ​

Interface ​

tsx
type Data = {
  elements: Element[];
  layout: {
    x: number;
    y: number;
    w: number;
    h: number;
    detail: {
      background?: string;
      overflow?: 'hidden' | 'visiable'; // default  'visiable'
    };
  };
};

Layout Properties ​

PropertyDescriptionTypeDefaultRequiredOthers
xX-axis offsetnumber-true-
yY-axis offsetnumber-true-
wLayout widthnumber-true-
hLayout heightnumber-true-
detailDetail of layoutobject (Please check the description of Typescript interface)-true-

Usage of Layout ​

js
import { iDraw } from 'idraw';

import { iDraw } from 'idraw';
const data = {
  elements: [
    /* ... */
  ],
  layout: {
    x: -100,
    y: -100,
    w: 800,
    h: 600,
    detail: {
      background: '#0000ff1F',
      overflow: 'hidden'
    }
  }
};

const app = document.querySelector('#app');
const idraw = new iDraw(app, {
  width: 600,
  height: 400,
  devicePixelRatio: 2
});

idraw.setData(data);

Demo Preview ​

More Demos >>