import * as React from 'react'; import JqxButton from 'jqwidgets-scripts/jqwidgets-react-tsx/jqxbuttons'; import JqxCheckBox, { ICheckBoxProps } from 'jqwidgets-scripts/jqwidgets-react-tsx/jqxcheckbox'; import JqxExpander from 'jqwidgets-scripts/jqwidgets-react-tsx/jqxexpander'; import JqxLinearGauge, { ILinearGaugeProps } from 'jqwidgets-scripts/jqwidgets-react-tsx/jqxlineargauge'; import JqxRadioButton from 'jqwidgets-scripts/jqwidgets-react-tsx/jqxradiobutton'; export interface IState extends ILinearGaugeProps { verticalChecked: ICheckBoxProps['checked']; showTicksChecked: ICheckBoxProps['checked']; showLabelsChecked: ICheckBoxProps['checked']; showRangesChecked: ICheckBoxProps['checked']; showBackgroundChecked: ICheckBoxProps['checked']; } class App extends React.PureComponent<{}, IState> { private myLinearGauge = React.createRef(); private bothLabelsRadioButton = React.createRef(); private bothTicksRadioButton = React.createRef(); constructor(props: {}) { super(props); this.isVerticalCheckboxOnChange = this.isVerticalCheckboxOnChange.bind(this); this.showTicksCheckboxOnChange = this.showTicksCheckboxOnChange.bind(this); this.showLabelsCheckboxOnChange = this.showLabelsCheckboxOnChange.bind(this); this.showRangesCheckboxOnChange = this.showRangesCheckboxOnChange.bind(this); this.showBackgroundCheckboxOnChange = this.showBackgroundCheckboxOnChange.bind(this); this.labelsNearRadioOnChecked = this.labelsNearRadioOnChecked.bind(this); this.labelsFarRadioOnChecked = this.labelsFarRadioOnChecked.bind(this); this.labelsBothRadioOnChecked = this.labelsBothRadioOnChecked.bind(this); this.ticksNearRadioOnChecked = this.ticksNearRadioOnChecked.bind(this); this.ticksFarRadioOnChecked = this.ticksFarRadioOnChecked.bind(this); this.ticksBothRadioOnChecked = this.ticksBothRadioOnChecked.bind(this); this.showAnimationButtonOnClick = this.showAnimationButtonOnClick.bind(this); this.state = { background: { visible: true }, height: '300px', labels: { interval: 20 }, orientation: 'vertical', pointer: { size: '6%' }, ranges: [ { startValue: -10, endValue: 10, style: { fill: '#FFF157', stroke: '#FFF157' } }, { startValue: 10, endValue: 35, style: { fill: '#FFA200', stroke: '#FFA200' } }, { startValue: 35, endValue: 60, style: { fill: '#FF4800', stroke: '#FF4800' } } ], showBackgroundChecked: true, showLabelsChecked: true, showRanges: true, showRangesChecked: true, showTicksChecked: true, ticksMajor: { visible: true, interval: 10, size: '10%' }, ticksMinor: { visible: true, size: '5%', interval: 2.5, style: { 'stroke-width': 1, stroke: '#aaaaaa' } }, verticalChecked: true, width: '100px' } } public componentDidMount() { this.myLinearGauge.current!.setOptions({ value: 50 }); this.bothLabelsRadioButton.current!.setOptions({ checked: true }); this.bothTicksRadioButton.current!.setOptions({ checked: true }); } public render() { return (
Options
Is Vertical
Labels position:
Near
Far
Both
Ticks position:
Near
Far
Both

Show Ticks Show Labels Show Ranges Show Background
Reset Value
); } private isVerticalCheckboxOnChange(event: any): void { if (event.args.checked) { this.setState({ height: '300px', orientation: 'vertical', verticalChecked: true, width: '100px' }); } else { this.setState({ height: '100px', orientation: 'horizontal', verticalChecked: false, width: '300px' }); } }; private showTicksCheckboxOnChange(event: any): void { if (event.args.checked) { this.setState({ showTicksChecked: true, ticksMajor: { visible: true, size: '10%', interval: 10 }, ticksMinor: { visible: true, size: '5%', interval: 2.5, style: { 'stroke-width': 1, stroke: '#aaaaaa' } } }); } else { this.setState({ showTicksChecked: false, ticksMajor: { visible: false }, ticksMinor: { visible: false } }); } }; private showLabelsCheckboxOnChange(event: any): void { if (event.args.checked) { this.setState({ labels: { visible: true, interval: 20 }, showLabelsChecked: true }); } else { this.setState({ labels: { visible: false }, showLabelsChecked: false }); } }; private showRangesCheckboxOnChange(event: any): void { if (event.args.checked) { this.setState({ showRanges: true, showRangesChecked: true }); } else { this.setState({ showRanges: false, showRangesChecked: false }); } }; private showBackgroundCheckboxOnChange(event: any): void { if (event.args.checked) { this.setState({ background: { visible: true }, showBackgroundChecked: true }); } else { this.setState({ background: { visible: false }, showBackgroundChecked: false }); } }; private labelsNearRadioOnChecked(): void { this.setState({ labels: { interval: 20, position: 'near' } }); }; private labelsFarRadioOnChecked(): void { this.setState({ labels: { interval: 20, position: 'far' } }); }; private labelsBothRadioOnChecked(): void { this.setState({ labels: { interval: 20, position: 'both' } }); }; private ticksNearRadioOnChecked(): void { this.setState({ ticksPosition: 'near' }); }; private ticksFarRadioOnChecked(): void { this.setState({ ticksPosition: 'far' }); }; private ticksBothRadioOnChecked(): void { this.setState({ ticksPosition: 'both' }); }; private showAnimationButtonOnClick(): void { this.myLinearGauge.current!.setOptions({ animationDuration: 0 }); this.myLinearGauge.current!.setOptions({ value: -60 }); this.myLinearGauge.current!.setOptions({ animationDuration: 1000 }); this.myLinearGauge.current!.setOptions({ value: 50 }); }; } export default App;