JavaScript/jQuery Chart - size
Type:
Default Value: undefined
The Chart's default size is width: 400px; height: 400px
. You can specify custom width and height for the component:
Fixed
Assign values to the size object's height and width properties.Relative
Specify a container for the component. The Chart occupies the container area.
NOTE
The size object has priority over the container.
Assign 0 to the size object's height and width properties to hide the Chart component.
jQuery
index.js
$(function() { $("#chartContainer").dxChart({ // ... size: { height: 300, width: 600 } }); });
Angular
app.component.html
app.component.ts
app.module.ts
<dx-chart ... > <dxo-size [height]="300" [width]="600"> </dxo-size> </dx-chart>
import { Component } from '@angular/core'; @Component({ selector: 'app-root', templateUrl: './app.component.html', styleUrls: ['./app.component.css'] }) export class AppComponent { // ... }
import { BrowserModule } from '@angular/platform-browser'; import { NgModule } from '@angular/core'; import { AppComponent } from './app.component'; import { DxChartModule } from 'devextreme-angular'; @NgModule({ declarations: [ AppComponent ], imports: [ BrowserModule, DxChartModule ], providers: [ ], bootstrap: [AppComponent] }) export class AppModule { }
Vue
App.vue
<template> <DxChart ... > <DxSize :height="300" :width="600" /> </DxChart> </template> <script> import DxChart, { DxSize } from 'devextreme-vue/chart'; export default { components: { DxChart, DxSize }, // ... } </script>
React
App.js
import React from 'react'; import Chart, { Size } from 'devextreme-react/chart'; class App extends React.Component { render() { return ( <Chart ... > <Size height={300} width={600} /> </Chart> ); } } export default App;
Alternatively, you can use CSS to style the UI component's container:
jQuery
index.js
styles.css
$(function() { $("#chart").dxChart({ // ... }); });
#chart { width: 85%; height: 70%; }
Angular
app.component.html
app.styles.css
<dx-chart ... id="chart"> </dx-chart>
#chart { width: 85%; height: 70%; }
Vue
App.vue
<template> <DxChart ... id="chart"> </DxChart> </template> <script> import DxChart from 'devextreme-vue/chart'; export default { components: { DxChart }, // ... } </script> <style> #chart { width: 85%; height: 70%; } </style>
React
App.js
styles.css
import React from 'react'; import Chart from 'devextreme-react/chart'; class App extends React.Component { render() { return ( <Chart ... id="chart"> </Chart> ); } } export default App;
#chart { width: 85%; height: 70%; }
Feedback