@orbis-systems/orbis-chart-react
Advanced tools
Comparing version 0.0.5 to 0.0.6
import React from 'react'; | ||
import isEqual from 'lodash.isequal'; | ||
@@ -12,5 +13,7 @@ const SCRIPT_ID = 'orbis-chart-script'; | ||
}; | ||
this.componentDidUpdate = () => { | ||
this.cleanupWidget(); | ||
this.initWidget(); | ||
this.componentDidUpdate = (prevProps) => { | ||
if (!isEqual(prevProps.chartConfig, this.props.chartConfig)) { | ||
this.cleanupWidget(); | ||
this.initWidget(); | ||
} | ||
}; | ||
@@ -43,3 +46,3 @@ this.canUseDOM = () => !!(typeof window !== 'undefined' && | ||
script.async = true; | ||
script.src = (_a = this.props.apiUrl) !== null && _a !== void 0 ? _a : 'https://charts.orbis.dev/js/chart-axios.js'; | ||
script.src = (_a = this.props.libUrl) !== null && _a !== void 0 ? _a : 'https://charts.orbis.dev/js/chart-axios.js'; | ||
script.onload = callback; | ||
@@ -52,4 +55,4 @@ document.getElementsByTagName('head')[0].appendChild(script); | ||
} | ||
const { libPath = 'https://charts.orbis.dev/api/', quoteType = 'delayed', updateInterval = 2000, chartConfig, } = this.props; | ||
new TradingView.widget(Object.assign(Object.assign({ locale: 'en', interval: 'D', autosize: true, library_path: 'charting/' }, chartConfig), { container_id: this.containerId, datafeed: new OrbisDatafeed(libPath, updateInterval, quoteType) })); | ||
const { apiUrl = 'https://charts.orbis.dev/api/', quoteType = 'delayed', updateInterval = 2000, chartConfig, } = this.props; | ||
new TradingView.widget(Object.assign(Object.assign({ locale: 'en', interval: 'D', library_path: '/charting/' }, chartConfig), { container_id: this.containerId, datafeed: new OrbisDatafeed(apiUrl, updateInterval, quoteType) })); | ||
}; | ||
@@ -65,13 +68,6 @@ this.cleanupWidget = () => { | ||
}; | ||
this.getStyle = () => { | ||
var _a; | ||
if (!((_a = this.props.chartConfig) === null || _a === void 0 ? void 0 : _a.autosize)) { | ||
return {}; | ||
} | ||
return { | ||
width: '100%', | ||
height: '100%' | ||
}; | ||
}; | ||
this.render = () => React.createElement("div", { id: this.containerId, style: this.getStyle() }); | ||
this.render = () => React.createElement("div", { id: this.containerId, style: { | ||
width: this.props.chartConfig.autosize ? '100%' : undefined, | ||
height: this.props.chartConfig.autosize ? '100%' : undefined, | ||
} }); | ||
} | ||
@@ -78,0 +74,0 @@ } |
@@ -5,3 +5,3 @@ import React from 'react'; | ||
apiUrl?: string; | ||
libPath?: string; | ||
libUrl?: string; | ||
quoteType?: 'delayed' | 'stock'; | ||
@@ -16,3 +16,3 @@ updateInterval?: number; | ||
componentDidMount: () => void; | ||
componentDidUpdate: () => void; | ||
componentDidUpdate: (prevProps: Props) => void; | ||
canUseDOM: () => boolean; | ||
@@ -22,11 +22,4 @@ appendScript: (callback: () => void) => void; | ||
cleanupWidget: () => void; | ||
getStyle: () => { | ||
width?: undefined; | ||
height?: undefined; | ||
} | { | ||
width: string; | ||
height: string; | ||
}; | ||
render: () => JSX.Element; | ||
} | ||
export default OrbisChart; |
{ | ||
"name": "@orbis-systems/orbis-chart-react", | ||
"version": "0.0.5", | ||
"version": "0.0.6", | ||
"description": "", | ||
@@ -26,3 +26,5 @@ "main": "dist/index.js", | ||
"homepage": "https://github.com/OrbisSystems/orbis-chart-react", | ||
"dependencies": {}, | ||
"dependencies": { | ||
"lodash.isequal": "^4.5.0" | ||
}, | ||
"peerDependencies": { | ||
@@ -42,2 +44,3 @@ "react": "^16.13.1" | ||
"@types/jquery": "^3.5.0", | ||
"@types/lodash.isequal": "^4.5.5", | ||
"@types/react": "^16.9.43", | ||
@@ -44,0 +47,0 @@ "@types/react-dom": "^16.9.8", |
61124
2
26
1629
+ Addedlodash.isequal@^4.5.0
+ Addedlodash.isequal@4.5.0(transitive)