react-tradingview-widget
Advanced tools
Comparing version 1.0.1 to 1.1.0
@@ -1,1 +0,1 @@ | ||
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports["react-tradingview-widget"]=t():e["react-tradingview-widget"]=t()}("undefined"!=typeof self?self:this,function(){return webpackJsonpreact_tradingview_widget([1],[,function(e,t,n){"use strict";function i(e,t){var n={};for(var i in e)t.indexOf(i)>=0||Object.prototype.hasOwnProperty.call(e,i)&&(n[i]=e[i]);return n}function r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function o(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function a(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}Object.defineProperty(t,"__esModule",{value:!0});var c=n(2),s=n.n(c),p=n(6),l=n.n(p),d=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var i in n)Object.prototype.hasOwnProperty.call(n,i)&&(e[i]=n[i])}return e},u=function(e){function t(){var e,n,a,c;r(this,t);for(var p=arguments.length,l=Array(p),u=0;u<p;u++)l[u]=arguments[u];return n=a=o(this,(e=t.__proto__||Object.getPrototypeOf(t)).call.apply(e,[this].concat(l))),a.componentDidMount=function(){a.appendScript(a.initWidget)},a.appendScript=function(e){if(a.scriptExists())return void e();var t=document.createElement("script");t.id="widget-script",t.type="text/javascript",t.async=!0,t.src="https://s3.tradingview.com/tv.js",t.onload=e,document.getElementsByTagName("head")[0].appendChild(t)},a.scriptExists=function(){return null!==document.getElementById("widget-script")},a.initWidget=function(){var e=a.props,t=e.widgetType,n=i(e,["widgetType"]),r=d({},n,{container_id:"widget-container"});new TradingView[t](r)},a.render=function(){return s.a.createElement("div",{id:"widget-container"})},c=n,o(a,c)}return a(t,e),t}(c.Component);u.propTypes={widgetType:l.a.string,width:l.a.number,height:l.a.number,symbol:l.a.string.isRequired,interval:l.a.string,timezone:l.a.string,theme:l.a.string,style:l.a.string,locale:l.a.string,toolbar_bg:l.a.string,enable_publishing:l.a.bool,allow_symbol_change:l.a.bool,hideideas:l.a.bool},u.defaultProps={widgetType:"widget",width:980,height:610,interval:"D",timezone:"Etc/UTC",theme:"Light",style:"1",locale:"en",toolbar_bg:"#F1F3F6",enable_publishing:!1,allow_symbol_change:!0,hideideas:!0},t.default=u}],[1])}); | ||
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports["react-tradingview-widget"]=t():e["react-tradingview-widget"]=t()}("undefined"!=typeof self?self:this,function(){return webpackJsonpreact_tradingview_widget([1],[,function(e,t,n){"use strict";function o(e,t){var n={};for(var o in e)t.indexOf(o)>=0||Object.prototype.hasOwnProperty.call(e,o)&&(n[o]=e[o]);return n}function i(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function r(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function a(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}Object.defineProperty(t,"__esModule",{value:!0}),n.d(t,"IntervalTypes",function(){return d}),n.d(t,"Themes",function(){return f}),n.d(t,"BarStyles",function(){return g});var p=n(2),s=n.n(p),l=n(6),u=n.n(l),c=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var o in n)Object.prototype.hasOwnProperty.call(n,o)&&(e[o]=n[o])}return e},d={D:"D",W:"W"},f={LIGHT:"Light",DARK:"Dark"},g={BARS:"0",CANDLES:"1",HOLLOW_CANDLES:"9",HEIKIN_ASHI:"8",LINE:"2",AREA:"3",RENKO:"4",LINE_BREAK:"7",KAGI:"5",POINT_AND_FIGURE:"6"},h=function(e){function t(){var e,n,a,p;i(this,t);for(var l=arguments.length,u=Array(l),d=0;d<l;d++)u[d]=arguments[d];return n=a=r(this,(e=t.__proto__||Object.getPrototypeOf(t)).call.apply(e,[this].concat(u))),a.componentDidMount=function(){a.appendScript(a.initWidget)},a.appendScript=function(e){if(a.scriptExists())return void e();var t=document.createElement("script");t.id="widget-script",t.type="text/javascript",t.async=!0,t.src="https://s3.tradingview.com/tv.js",t.onload=e,document.getElementsByTagName("head")[0].appendChild(t)},a.scriptExists=function(){return null!==document.getElementById("widget-script")},a.initWidget=function(){var e=a.props,t=e.widgetType,n=o(e,["widgetType"]),i=c({},n,{container_id:"widget-container"});i.autosize&&(delete i.width,delete i.height),"number"==typeof i.interval&&(i.interval=i.interval.toString()),i.popup_width&&"number"==typeof i.popup_width&&(i.popup_width=i.popup_width.toString()),i.popup_height&&"number"==typeof i.popup_height&&(i.popup_height=i.popup_height.toString()),new TradingView[t](i)},a.render=function(){return s.a.createElement("div",{id:"widget-container"})},p=n,r(a,p)}return a(t,e),t}(p.Component);h.propTypes={widgetType:u.a.string,width:u.a.number,height:u.a.number,autosize:u.a.bool,symbol:u.a.string.isRequired,interval:u.a.oneOf([1,3,5,15,30,60,120,180,"1","3","5","15","30","60","120","180",d.D,d.W]),timezone:u.a.string,theme:u.a.oneOf([f.LIGHT,f.DARK]),style:u.a.oneOf([g.BARS,g.CANDLES,g.HOLLOW_CANDLES,g.HEIKIN_ASHI,g.LINE,g.AREA,g.RENKO,g.LINE_BREAK,g.KAGI,g.POINT_AND_FIGURE]),locale:u.a.string,toolbar_bg:u.a.string,enable_publishing:u.a.bool,allow_symbol_change:u.a.bool,withdateranges:u.a.bool,hide_side_toolbar:u.a.bool,hideideas:u.a.bool,watchlist:u.a.arrayOf(u.a.string),details:u.a.bool,hotlist:u.a.bool,calendar:u.a.bool,news:u.a.arrayOf(u.a.string),studies:u.a.arrayOf(u.a.string),show_popup_button:u.a.bool,popup_width:u.a.oneOfType([u.a.number,u.a.string]),popup_height:u.a.oneOfType([u.a.number,u.a.string]),no_referral_id:u.a.bool,referral_id:u.a.string},h.defaultProps={widgetType:"widget",width:980,height:610,autosize:!1,interval:d.D,timezone:"Etc/UTC",theme:f.LIGHT,style:g.CANDLES,locale:"en",toolbar_bg:"#F1F3F6",enable_publishing:!1,allow_symbol_change:!0,hideideas:!0},t.default=h}],[1])}); |
{ | ||
"name": "react-tradingview-widget", | ||
"version": "1.0.1", | ||
"version": "1.1.0", | ||
"repository": { | ||
@@ -18,3 +18,2 @@ "type": "git", | ||
"test": "jest", | ||
"deploy": "npm publish", | ||
"coverage": "jest --coverage", | ||
@@ -21,0 +20,0 @@ "lint": "eslint ./src" |
# react-tradingview-widget | ||
React component for rendering TradingView Advanced Real-Time Chart Widget. | ||
React component for rendering [TradingView Advanced Real-Time Chart Widget](https://www.tradingview.com/widget/advanced-chart/). | ||
@@ -19,7 +19,7 @@ ## Install | ||
All given props are passed on to the widget config. | ||
All given props are passed on to the widget config. See [this page](https://www.tradingview.com/widget/advanced-chart/) for the TradingView Advanced Real-Time Chart API. | ||
### Advanced example | ||
```javascript | ||
import TradingViewWidget from 'react-tradingview-widget'; | ||
import TradingViewWidget, { Themes } from 'react-tradingview-widget'; | ||
@@ -29,3 +29,3 @@ const App = () => ( | ||
symbol="NASDAQ:AAPL" | ||
theme="Dark" | ||
theme={Themes.DARK} | ||
locale="fr" | ||
@@ -35,3 +35,22 @@ autosize | ||
); | ||
``` | ||
``` | ||
## Constants and API differences | ||
react-tradingview-widget exports constants for the following things: | ||
- Interval types: `IntervalTypes.D` and `IntervalTypes.W` | ||
- Themes: `Themes.LIGHT` and `Themes.DARK` | ||
- BarStyles: | ||
- `BarStyles.BARS` | ||
- `BarStyles.CANDLES` | ||
- `BarStyles.HOLLOW_CANDLES` | ||
- `BarStyles.HEIKIN_ASHI` | ||
- `BarStyles.LINE` | ||
- `BarStyles.AREA` | ||
- `BarStyles.RENKO` | ||
- `BarStyles.LINE_BREAK` | ||
- `BarStyles.KAGI` | ||
- `BarStyles.POINT_AND_FIGURE` | ||
You don't have to use these constants. | ||
react-tradingview-widget also makes it possible to use numbers for `interval`, `popup_width` and `popup_height` instead of strings, but this is not required. |
@@ -7,57 +7,53 @@ import path from 'path'; | ||
export default () => ({ | ||
entry: { | ||
index: path.join(__dirname, 'src/index.js'), | ||
}, | ||
entry: { | ||
index: path.join(__dirname, 'src/index.js') | ||
}, | ||
output: { | ||
path: path.join(__dirname, 'dist'), | ||
filename: '[name].js', | ||
library: packageJson.name, | ||
libraryTarget: 'umd', | ||
}, | ||
output: { | ||
path: path.join(__dirname, 'dist'), | ||
filename: '[name].js', | ||
library: packageJson.name, | ||
libraryTarget: 'umd' | ||
}, | ||
module: { | ||
rules: [ | ||
{ | ||
test: /.jsx?$/, | ||
exclude: /node_modules/, | ||
include: path.join(__dirname, 'src'), | ||
use: [ | ||
{ | ||
loader: 'babel-loader', | ||
options: { | ||
babelrc: false, | ||
presets: [ | ||
['es2015', { modules: false }], | ||
'react', | ||
'stage-0' | ||
], | ||
} | ||
} | ||
] | ||
}, | ||
{ | ||
test: /\.(css)$/, | ||
loader: 'style-loader!css-loader', | ||
}, | ||
module: { | ||
rules: [ | ||
{ | ||
test: /.jsx?$/, | ||
exclude: /node_modules/, | ||
include: path.join(__dirname, 'src'), | ||
use: [ | ||
{ | ||
loader: 'babel-loader', | ||
options: { | ||
babelrc: false, | ||
presets: [['es2015', { modules: false }], 'react', 'stage-0'] | ||
} | ||
} | ||
] | ||
}, | ||
}, | ||
{ | ||
test: /\.(css)$/, | ||
loader: 'style-loader!css-loader' | ||
} | ||
] | ||
}, | ||
plugins: [ | ||
// Clean dist folder | ||
new CleanWebpackPlugin(['dist/*.*']), | ||
plugins: [ | ||
// Clean dist folder | ||
new CleanWebpackPlugin(['dist/*.*']), | ||
//CommonChunksPlugin will now extract all the common modules from vendor and main bundles | ||
//https://medium.com/@adamrackis/vendor-and-code-splitting-in-webpack-2-6376358f1923 | ||
new webpack.optimize.CommonsChunkPlugin({ | ||
name: 'vendor', | ||
minChunks(module) { | ||
return module.context && module.context.indexOf('node_modules') !== -1; | ||
}, | ||
}), | ||
//CommonChunksPlugin will now extract all the common modules from vendor and main bundles | ||
//https://medium.com/@adamrackis/vendor-and-code-splitting-in-webpack-2-6376358f1923 | ||
new webpack.optimize.CommonsChunkPlugin({ | ||
name: 'vendor', | ||
minChunks(module) { | ||
return module.context && module.context.indexOf('node_modules') !== -1; | ||
} | ||
}), | ||
new webpack.optimize.CommonsChunkPlugin({ | ||
name: 'manifest' | ||
}) | ||
] | ||
new webpack.optimize.CommonsChunkPlugin({ | ||
name: 'manifest' | ||
}) | ||
] | ||
}); |
258131
14
54
119