我尝试计算每ASK
BID
和row
之间的百分比差异,并使用DIFF
将其显示在widget-math.js
列上
这是我的表:
我已选择此选项:
widgets: ["zebra", "filter", 'math'],
widgetOptions : {
math_data : 'math', // data-math attribute
math_ignore : [0, 1],
math_complete : function($cell, wo, result) {
var pct = result;
return pct ;
}
此功能:
$.tablesorter.equations['custom'] = function(arry) {
// (a+b+c)*d - (e/f)*100
return 100 * (arry[4]/arry[5]) / arry[4];
};
html看起来像:
<table id="myTable" class="tablesorter">
<thead>
<tr>
<th>EXCHANGE</th>
<th>PAIR</th>
<th>ASK QUANTITY</th>
<th>ASK TOTAL</th>
<th>ASK</th>
<th>BID</th>
<th>BID TOTAL</th>
<th>BID QUANTITY</th>
<th>DIFF</th>
</tr>
</thead>
<tbody> <tr>
<th>Liqui.io</th>
<th>AE/ETH</th>
<td>201.0782718600</td>
<td>0.2855070166</td>
<td>0.0014198800</td>
<td>0.0013974500</td>
<td>0.0100000000</td>
<td>7.1558910900</td>
<td data-math="row-custom"></td>
</tr> <tr>
<th>Etherdelta</th>
<th>AE/ETH</th>
<td>3.741.9966441793</td>
<td>5.5344130367</td>
<td>0.0014790000</td>
<td>0.0013830000</td>
<td>0.3071114810</td>
<td>222.0618083940</td>
<td data-math="row-custom"></td>
</tr></tbody>
</table>
由于某种原因,它显示一个空白单元格。知道什么是错的?
信息:
tablesorter版本:&#39; 2.28.15&#39;
jQuery版本:3.2.1