I am using Tabulator 6.2 on PC. I am loading data into a column CurrentPrice from websocket(stock prices) that updates rapidly. Works great. I have another column for the InitialPrice — I do not wish this column to update.(It should keep the initial price).
I am trying to get the price difference (CurrentPrice – InitialPrice = PriceDifference).
I have tried Tabulator formatter and it works, but I need a mutator so I can mutateLink InitialPrice to PriceDifference column.
Here is the mutator I have tried (and many other ways):
{title:"CurrentPrice", field:"cprice", hozAlign:"center", width: "4pt",
mutateLink:Pdiff,
mutator: function(value, data) {
value = cprice;
return value }},
{title:"InitialPrice ", field:"inprice", hozAlign:"center", width: "4pt",
mutateLink:Pdiff,
mutator: function(value, data) {
inprice = cell.getInitialValue();
return inprice }},
{title:"PDiff ", field:"Pdiff", hozAlign:"center", width: "4pt",
mutator: function(value, data) {
value = data.cprice - data.inprice // (does not work,cannot get data.inprice)
return value }},
Here is js loading code, it works great .
if (json.cmd === "DataUpdate" )
var Nsym = json.result.sym;
var Lprice = json.result.price.toFixed(2);
var LVol = json.result.volume;
table.updateData([{ Ticker:Nsym, nowprice:Lprice,nowVol:LVol, buyQty:BuyQty }]);
All Tickers and Company Names are are loaded into table on startup.
What am I doing wrong with the mutator? Or is there another way to solve this issue? Creating a stop loading function? Create a static cell option? or ??
Thanks, Roger