@ -884,22 +884,100 @@ function private:GetGoldGraphSumData()
return private : GetGoldGraphPoints ( temp )
end
function GUI : DrawGoldGraph ( container )
TSM.db . realm.goldGraphCharacter = TSM.db . realm.goldGraphCharacter or UnitName ( " player " )
local player = TSM.db . realm.goldGraphCharacter
local data , minX , maxX , minY , maxY
function private : GetWealthPrice ( itemString )
local avgSell = TSM : GetAvgSellPrice ( itemString )
local marketValue = TSMAPI : GetItemValue ( itemString , " DBMarket " )
if avgSell and marketValue then
return ( avgSell + marketValue ) / 2
end
return avgSell or marketValue
end
function private : GetWealthTotals ( player )
local totals = {
bags = 0 ,
bank = 0 ,
auctions = 0 ,
}
local hasData = false
local function AddTotals ( itemData , key )
if not itemData then return end
hasData = true
for itemString , quantity in pairs ( itemData ) do
if quantity > 0 then
local price = private : GetWealthPrice ( itemString )
if price then
totals [ key ] = totals [ key ] + ( price * quantity )
end
end
end
end
if player == " <ALL> " then
data , minX , maxX , minY , maxY = private : GetGoldGraphSumData ( )
local players = TSMAPI : ModuleAPI ( " ItemTracker " , " playerlist " ) or { }
for _ , playerName in ipairs ( players ) do
AddTotals ( TSMAPI : ModuleAPI ( " ItemTracker " , " playerbags " , playerName ) , " bags " )
AddTotals ( TSMAPI : ModuleAPI ( " ItemTracker " , " playerbank " , playerName ) , " bank " )
AddTotals ( TSMAPI : ModuleAPI ( " ItemTracker " , " playerauctions " , playerName ) , " auctions " )
end
else
data , minX , maxX , minY , maxY = private : GetGoldGraphPoints ( TSM.db . realm.goldLog [ player ] )
AddTotals ( TSMAPI : ModuleAPI ( " ItemTracker " , " playerbags " , player ) , " bags " )
AddTotals ( TSMAPI : ModuleAPI ( " ItemTracker " , " playerbank " , player ) , " bank " )
AddTotals ( TSMAPI : ModuleAPI ( " ItemTracker " , " playerauctions " , player ) , " auctions " )
end
if not hasData then return end
return totals
end
function private : GetLatestGold ( player )
local function GetLogGold ( log )
if not log or # log == 0 then return end
return log [ # log ] . copper
end
if player == " <ALL> " then
local total = 0
local hasData = false
for name , log in pairs ( TSM.db . realm.goldLog ) do
local gold = GetLogGold ( log )
if gold then
total = total + gold
hasData = true
end
end
if not hasData then return end
return total
end
return GetLogGold ( TSM.db . realm.goldLog [ player ] )
end
function GUI : DrawGoldGraph ( container )
TSM.db . realm.goldGraphCharacter = TSM.db . realm.goldGraphCharacter or UnitName ( " player " )
local player = TSM.db . realm.goldGraphCharacter
local dropdownList = { [ " <ALL> " ] = " Sum of All Characters " }
for player in pairs ( TSM.db . realm.goldLog ) do
dropdownList [ player ] = player
end
if not data then
local wealthTotals = private : GetWealthTotals ( player )
local wealthTotalText = L [ " Not Available " ]
local wealthBagsText = L [ " Not Available " ]
local wealthBankText = L [ " Not Available " ]
local wealthAuctionsText = L [ " Not Available " ]
if wealthTotals then
wealthTotalText = TSMAPI : FormatTextMoney ( wealthTotals.bags + wealthTotals.bank + wealthTotals.auctions ) or " --- "
wealthBagsText = TSMAPI : FormatTextMoney ( wealthTotals.bags ) or " --- "
wealthBankText = TSMAPI : FormatTextMoney ( wealthTotals.bank ) or " --- "
wealthAuctionsText = TSMAPI : FormatTextMoney ( wealthTotals.auctions ) or " --- "
end
local coinTotal = private : GetLatestGold ( player )
local coinTotalText = coinTotal and TSMAPI : FormatTextMoney ( coinTotal ) or L [ " Not Available " ]
local page = {
{
type = " SimpleGroup " ,
@ -907,103 +985,66 @@ function GUI:DrawGoldGraph(container)
children = {
{
type = " Label " ,
text = L [ " Accounting has not yet collected enough information for this tab. This is likely due to not having recorded enough data points or not seeing any significant fluctuations in your gold on hand. " ] ,
text = L [ " Player Gold " ] ,
relativeWidth = 1 ,
} ,
{
type = " Spacer " ,
} ,
-- {
-- type = "Spacer" ,
-- } ,
{
type = " Dropdown " ,
label = "Character to Graph " ,
label = L [ "Character to Graph " ] ,
settingInfo = { TSM.db . realm , " goldGraphCharacter " } ,
relativeWidth = 0.5 ,
list = dropdownList ,
callback = function ( ) container : ReloadTab ( ) end ,
tooltip = " " ,
} ,
} ,
} ,
}
TSMAPI : BuildPage ( container , page )
return
end
local startDate , endDate
if TSM.db . realm.timeFormat == " eudate " then
startDate = date ( " %d/%m/%y %H:%M " , minX * 60 )
endDate = date ( " %d/%m/%y %H:%M " , maxX * 60 )
elseif TSM.db . realm.timeFormat == " aidate " then
startDate = date ( " %y/%m/%d %H:%M " , minX * 60 )
endDate = date ( " %y/%m/%d %H:%M " , maxX * 60 )
else
startDate = date ( " %m/%d/%y %H:%M " , minX * 60 )
endDate = date ( " %m/%d/%y %H:%M " , maxX * 60 )
end
local page = {
{
type = " Simpl eGroup" ,
type = " InlineGroup " ,
layout = " Flow " ,
title = L [ " Player Wealth " ] ,
backdrop = true ,
children = {
{
type = " Label " ,
text = format ( L [ " Below is a graph of the your character's gold on hand over time. \n \n The x-axis is time and goes from %s to %s \n The y-axis is gold. " ] , startDate , endDate ) ,
text = L [ " Total: " ] .. " " .. wealthTotalText ,
relativeWidth = 1 ,
} ,
-- {
-- type = "Spacer",
-- },
{
type = " Dropdown " ,
label = L [ " Character to Graph " ] ,
settingInfo = { TSM.db . realm , " goldGraphCharacter " } ,
relativeWidth = 0.5 ,
list = dropdownList ,
callback = function ( ) container : ReloadTab ( ) end ,
type = " Label " ,
text = L [ " Bags: " ] .. " " .. wealthBagsText ,
relativeWidth = 0.33 ,
} ,
-- {
-- type = "HeadingLine"
-- },
{
type = " Spacer " ,
type = " Label " ,
text = L [ " Bank: " ] .. " " .. wealthBankText ,
relativeWidth = 0.33 ,
} ,
{
type = " ScrollFrame " ,
fullHeight = false , --true
layout = " flow "
type = " Label " ,
text = L [ " Auctions: " ] .. " " .. wealthAuctionsText ,
relativeWidth = 0.33 ,
} ,
} ,
} ,
{
type = " InlineGroup " ,
layout = " Flow " ,
title = L [ " Coin on Hand " ] ,
backdrop = true ,
children = {
{
type = " Label " ,
text = L [ " Total: " ] .. " " .. coinTotalText ,
relativeWidth = 1 ,
} ,
} ,
} ,
} ,
} ,
}
TSMAPI : BuildPage ( container , page )
local parent = container.children [ 1 ] . children [ # container.children [ 1 ] . children ] . frame
parent : SetWidth ( container.frame : GetWidth ( ) - 80 )
parent : SetHeight ( container.frame : GetHeight ( ) - 140 )
--if not GUI.lineGraph then
local graph = LibStub ( " LibGraph-2.0 " ) : CreateGraphLine ( nil , parent , " CENTER " , nil , nil , nil , parent : GetWidth ( ) , parent : GetHeight ( ) )
graph : SetGridColor ( { 0.8 , 0.8 , 0.8 , 0.6 } )
graph : SetYLabels ( true )
GUI.lineGraph = graph
--end
GUI.lineGraph : Show ( )
GUI.lineGraph : SetParent ( parent )
GUI.lineGraph : ClearAllPoints ( )
GUI.lineGraph : SetAllPoints ( parent )
GUI.lineGraph : ResetData ( )
local ySpacing = max ( ceil ( ( maxY - minY ) / 20 ) , 0.5 )
GUI.lineGraph : SetGridSpacing ( nil , ySpacing )
local xBuffer = ( maxX - minX ) * 0.05
local yBuffer = ( maxY - minY ) * 0.03
GUI.lineGraph : SetXAxis ( minX - xBuffer , maxX )
GUI.lineGraph : SetYAxis ( minY - yBuffer , maxY + yBuffer )
GUI.lineGraph : AddDataSeries ( data , { 1 , 0.83 , 0 , 1 } )
GUI.lineGraph : RefreshGraph ( )
end
function GUI : DrawOptions ( container )