Search results

Linear Gauge Dimensions in React Linear Gauge component

14 Apr 2021 / 2 minutes to read

Size for Container

Linear gauge can render to its container size. You can set the size via inline or CSS as demonstrated below.

Copied to clipboard
 <div id="charts" style="width:650px; height:350px"></div>
Source
Preview
index.tsx
index.jsx
Copied to clipboard
import * as React from "react";
import * as ReactDOM from "react-dom";
import { LinearGaugeComponent } from '@syncfusion/ej2-react-lineargauge';

ReactDOM.render(
    <LinearGaugeComponent id='gauge'>
    </LinearGaugeComponent>,document.getElementById('gauge'));
Copied to clipboard
import * as React from "react";
import * as ReactDOM from "react-dom";
import { LinearGaugeComponent } from '@syncfusion/ej2-react-lineargauge';
ReactDOM.render(<LinearGaugeComponent id='gauge'>
    </LinearGaugeComponent>, document.getElementById('gauge'));

Size for Linear Gauge

You can also set size for linear gauge directly through width and height properties.

In Pixel

You can set the size of lineargauge in pixel as demonstrated below.

Source
Preview
index.tsx
index.jsx
Copied to clipboard
import * as React from "react";
import * as ReactDOM from "react-dom";
import { LinearGaugeComponent } from '@syncfusion/ej2-react-lineargauge';

ReactDOM.render(
    <LinearGaugeComponent id='gauge' width='650px' height='350px'>
    </LinearGaugeComponent>,document.getElementById('gauge'));
Copied to clipboard
import * as React from "react";
import * as ReactDOM from "react-dom";
import { LinearGaugeComponent } from '@syncfusion/ej2-react-lineargauge';
ReactDOM.render(<LinearGaugeComponent id='gauge' width='650px' height='350px'>
    </LinearGaugeComponent>, document.getElementById('gauge'));

In Percentage

By setting value in percentage, linear gauge gets its dimension with respect to its container. For example, when the height is ‘50%’, linear gauge renders to half of the container height.

Copied to clipboard
    <div id='container'>
        <div id='element' style="width:1000px; height:600px;"></div>
    </div>
Source
Preview
index.tsx
index.jsx
Copied to clipboard
import * as React from "react";
import * as ReactDOM from "react-dom";
import { LinearGaugeComponent } from '@syncfusion/ej2-react-lineargauge';

ReactDOM.render(
    <LinearGaugeComponent id='gauge' width='100%' height='50%'>
    </LinearGaugeComponent>,document.getElementById('gauge'));
Copied to clipboard
import * as React from "react";
import * as ReactDOM from "react-dom";
import { LinearGaugeComponent } from '@syncfusion/ej2-react-lineargauge';
ReactDOM.render(<LinearGaugeComponent id='gauge' width='100%' height='50%'>
    </LinearGaugeComponent>, document.getElementById('gauge'));

Note: When you do not specify the size, it takes 450px as the height and window size as its width.