Skip to content

Commit

Permalink
fix undefined amount bug
Browse files Browse the repository at this point in the history
  • Loading branch information
chxj1992 committed Mar 10, 2018
1 parent d1ee022 commit 63aea09
Show file tree
Hide file tree
Showing 6 changed files with 42,334 additions and 12 deletions.
42,263 changes: 42,262 additions & 1 deletion dist/kline.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/kline.js.map

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions dist/kline.min.js

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions examples/stomp.html
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,10 @@ <h1>K线图</h1>
theme: 'dark', // light/dark
language: 'zh-cn', // zh-cn/en-us/zh-tw
ranges: ["1w", "1d", "1h", "30m", "15m", "5m", "1m", "line"],
symbol: "BTC",
symbolName: "BTC/USD",
symbol: "ETH/BTC",
symbolName: "ETH/BTC",
type: "stomp", // poll/stomp
url: 'https://127.0.0.1/v1/socket',
url: 'https://10.200.172.67:50001/v1/socket',
limit: 1000,
intervalTime: 5000,
subscribePath: "/trade/kline",
Expand Down
8 changes: 4 additions & 4 deletions src/js/chart.js
Original file line number Diff line number Diff line change
Expand Up @@ -162,16 +162,16 @@ export class Chart {
_data.bids_si = _data.asks_count - 1;
_data.bids_ei = _data.asks_count + _data.bids_count - 2;
for (let i = _data.asks_si; i >= _data.asks_ei; i--) {
if (i === _data.asks_si) {
if (i === _data.asks_si && _data.array[i] !== undefined) {
_data.array[i].amounts = _data.array[i].amount;
} else {
} else if(_data.array[i + 1] !== undefined) {
_data.array[i].amounts = _data.array[i + 1].amounts + _data.array[i].amount;
}
}
for (let i = _data.bids_si; i <= _data.bids_ei; i++) {
if (i === _data.bids_si) {
if (i === _data.bids_si && _data.array[i] !== undefined) {
_data.array[i].amounts = _data.array[i].amount;
} else {
} else if (_data.array[i - 1] !== undefined) {
_data.array[i].amounts = _data.array[i - 1].amounts + _data.array[i].amount;
}
}
Expand Down
66 changes: 63 additions & 3 deletions webpack.config.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
const path = require('path');
const UglifyJsPlugin = require('uglifyjs-webpack-plugin');

module.exports = {
module.exports = [{
entry: './src/entry.js',
devtool: 'source-map',
output: {
path: path.resolve(__dirname, 'dist'),
filename: 'kline.js',
filename: 'kline.min.js',
libraryTarget: 'umd',
umdNamedDefine: true
},
Expand Down Expand Up @@ -60,5 +60,65 @@ module.exports = {
}
]
}
};
},
{
entry: './src/entry.js',
devtool: 'source-map',
output: {
path: path.resolve(__dirname, 'dist'),
filename: 'kline.js',
libraryTarget: 'umd',
umdNamedDefine: true
},
plugins: [
],
externals: {
jquery: {
commonjs: "jquery",
commonjs2: 'jquery',
amd: "jquery",
root: "$"
}
},
module: {
rules: [
{
test: /\.js$/,
exclude: /(node_modules|bower_components)/,
use: {
loader: 'babel-loader',
options: {
presets: [
'@babel/preset-env'
],
plugins: [
'transform-class-properties'
]
}
}
},
{
test: /\.css$/,
use: ['style-loader', 'css-loader']
},
{
test: /\.(png|jpg|gif|svg|eot|ttf|woff|woff2)$/,
loader: 'url-loader',
options: {
limit: 10000
}
},
{
test: /\.(html)$/,
use: {
loader: 'html-loader',
options: {
attrs: [':data-src']
}
}
}
]
}
}
];

0 comments on commit 63aea09

Please sign in to comment.