React Chart - Adaptive Layout

With the ever-growing variety of platforms, today's web sites and applications cannot stay competitive without being adaptive. Supporting this modern standard, the Chart UI component possesses an adaptive layout. This enables the Chart to hide its accessory elements if the container is not large enough to fit them. To configure the adaptive layout, use the adaptiveLayout object. Set its height and width fields to specify the minimum container size at which the layout retains all its elements.

App.js
  • import React from 'react';
  • import Chart, {
  • AdaptiveLayout
  • } from 'devextreme-react/chart';
  •  
  • class App extends React.Component {
  • render() {
  • return (
  • <Chart ... >
  • <AdaptiveLayout
  • height={300}
  • width={400}
  • />
  • </Chart>
  • );
  • }
  • }
  •  
  • export default App;

View Demo on JSFiddle

NOTE

The layout does not automatically adapt to changes made in the UI component's container at runtime. Therefore, if you enable a user to resize the container, call the render() method after each resizing to render the Chart in the new size.

App.js
  • import React from 'react';
  • import Chart from 'devextreme-react/chart';
  •  
  • class App extends React.Component {
  • constructor(props) {
  • super(props);
  •  
  • this.chartRef = React.createRef();
  • }
  •  
  • render() {
  • return (
  • <Chart ref={this.chartRef} ... >
  • </Chart>
  • );
  • }
  •  
  • renderChart () {
  • this.chartRef.current.instance.render();
  • }
  • }
  •  
  • export default App;
See Also