PTMagic/Monitor/Pages/SalesAnalyzer.cshtml

566 lines
27 KiB
Plaintext
Raw Permalink Normal View History

2018-05-22 10:11:50 +02:00
@page
@model SalesAnalyzer
2024-01-19 00:11:16 +01:00
@using System.Globalization
2018-05-22 10:11:50 +02:00
@{
ViewData["Title"] = "";
}
@section Styles {
<link href="@Html.Raw(Model.PTMagicConfiguration.GeneralSettings.Monitor.RootUrl)assets/plugins/tablesaw/css/tablesaw.css" rel="stylesheet" type="text/css" />
<link href="@Html.Raw(Model.PTMagicConfiguration.GeneralSettings.Monitor.RootUrl)assets/plugins/nvd3/nv.d3.min.css" rel="stylesheet" type="text/css" />
<link href="@Html.Raw(Model.PTMagicConfiguration.GeneralSettings.Monitor.RootUrl)assets/plugins/datatables/dataTables.bootstrap4.min.css" rel="stylesheet" type="text/css" />
<link href="@Html.Raw(Model.PTMagicConfiguration.GeneralSettings.Monitor.RootUrl)assets/plugins/datatables/buttons.bootstrap4.min.css" rel="stylesheet" type="text/css" />
}
2019-03-18 08:37:14 +01:00
<div class="row">
2019-03-18 16:56:38 +01:00
<div class="col-md-12">
2019-03-20 15:06:25 +01:00
<div class="card-box">
<table class="table table-striped table-sm">
<thead>
<tr>
@{
2024-01-16 17:56:52 +01:00
double totalCurrentValue = double.Parse(Model.PTData.Misc.TotalCurrentValue);
string totalCurrentValueString = Model.PTData.Misc.TotalCurrentValue;
2019-03-20 15:06:25 +01:00
}
2024-01-16 17:56:52 +01:00
<th class="m-t-0 header-title text-left">Total Current Value: &nbsp; <text class="text-autocolor"> @totalCurrentValueString @Model.Summary.MainMarket </text> <small> <i class="fa fa-info-circle text-muted" data-toggle="tooltip" data-placement="top" title="This is based on the Total Current Value reported by Profit Trailer."></i></small></th>
<th class="text-right">Starting Value: &nbsp; <text class="text-autocolor"> @Model.MiscData.StartBalance &nbsp; @Model.Summary.MainMarket </text> <small> <i class="fa fa-info-circle text-muted" data-toggle="tooltip" data-placement="top" title="This is the starting value set in your PT account settings."></i></small></th>
2019-03-20 15:06:25 +01:00
</tr>
</thead>
</table>
2019-03-19 17:13:41 +01:00
</div>
</div>
</div>
2024-01-16 17:56:52 +01:00
<div class="row">
<div class="col-md-6">
<div class="card-box px-2" style="height:320px;">
<h4 class="m-t-0 header-title"><b>Cumulative Profits</b>
@if (!Model.CumulativeProfitChartDataJSON.Equals("")) {
<div class="cumulative-profit-chart">
<svg style="height:300px;width:100%"></svg>
</div>
} else {
<p>Unable to load graph, no sales data found.</p>
}
</div>
</div>
<div class="col-md-6">
<div class="card-box px-2" style="height:320px;">
<h4 class="m-t-0 header-title"><b>Daily TCV</b>
@if (!Model.TCVChartDataJSON.Equals("")) {
<div class="TCV-chart">
<svg style="height:300px;width:100%"></svg>
</div>
} else {
<p>Unable to load graph, no sales data found.</p>
}
2019-03-19 17:13:41 +01:00
</div>
2019-03-18 08:37:14 +01:00
</div>
</div>
2024-01-19 00:11:16 +01:00
2018-05-22 10:11:50 +02:00
<div class="row">
2024-01-19 00:11:16 +01:00
<div class="col-md-6">
<div class="card-box px-3" style="height:340px;">
@{
var days = Math.Min(Model.DailyStats.Count, 30);
}
<h4 class="m-t-0 m-b-20 header-title"><b>Daily Buys/Sales (@days Days) </b>
<div class="sales-chart">
<svg style="height:300px;width:100%"></svg>
</div>
</div>
</div>
<div class="col-md-6">
<div class="card-box px-3" style="height:340px;">
<h4 class="m-t-0 m-b-20 header-title"><b>Daily Profit (All Time) </b>
@if (!Model.ProfitChartDataJSON.Equals("")) {
<div class="profit-chart">
<svg style="height:300px;width:100%"></svg>
</div>
} else {
<p>Unable to load graph, no sales data found.</p>
}
2018-05-22 10:11:50 +02:00
</div>
</div>
</div>
2024-01-19 00:11:16 +01:00
2018-05-22 10:11:50 +02:00
<div class="row">
<div class="col-md-6">
<div class="card-box">
@{
2024-01-19 00:11:16 +01:00
int totalDays = Model.PTData.DailyPNL.Count;
2024-01-16 17:56:52 +01:00
double startBalance = Model.MiscData.StartBalance;
2024-01-15 15:12:46 +01:00
double totalSales = Model.PTData.Stats.TotalSales;
double totalProfit = Model.PTData.Stats.TotalProfit;
double totalFundingFees = Model.PTData.Stats.FundingTotal;
2024-01-16 17:56:52 +01:00
double totalPercentGain = ((totalProfit + totalFundingFees) / startBalance) * 100;
2024-01-15 15:12:46 +01:00
double totalProfitFiat = @Math.Round((totalProfit + totalFundingFees) * Model.PTData.Misc.FiatConversionRate, 0);
double avgDailySales = @Math.Round(totalSales/totalDays, 1);
double avgDailyGain = totalPercentGain / totalDays;
2018-05-22 10:11:50 +02:00
2024-01-15 15:12:46 +01:00
var MonthlyAveragesResult = Model.MonthlyAverages(Model.PTData.MonthlyStats, Model.PTData.DailyPNL);
string startDate = MonthlyAveragesResult.startDate.ToString("d");
string endDate = MonthlyAveragesResult.endDate.ToString("d");
double totalMonths = Math.Round(MonthlyAveragesResult.totalMonths, 1);
double avgMonthlySales = @Math.Round(totalSales / totalMonths, 1);
double avgMonthlyProfit = totalProfit / totalMonths;
double avgMonthlyGain = totalPercentGain / totalMonths;
double avgMonthlyFunding = totalFundingFees / totalMonths;
}
2024-01-19 00:11:16 +01:00
<h4 class="m-t-0 header-title" style="display: inline;">Averages</h4>&nbsp;&nbsp;&nbsp;&nbsp;<span style="font-size: x-small"> (@startDate - @endDate)</span>
2018-05-22 10:11:50 +02:00
<table class="table table-striped table-sm">
<thead>
<tr>
<th></th>
<th class="text-right">Total</th>
2024-01-19 00:11:16 +01:00
<th class="text-right">AVG/Day</span></th>
2024-01-19 02:36:36 +01:00
<th class="text-right">AVG/Month</span> <small><i class="fa fa-info-circle text-muted" data-toggle="tooltip" data-placement="top"
title="Months are based on the size of the calendar months. Weighted to compensate for partial months."></i></small></th>
2018-05-22 10:11:50 +02:00
</tr>
</thead>
<tbody>
<tr>
<th>Sales</th>
2024-01-15 15:12:46 +01:00
<td class="text-right">@totalSales</td>
<td class="text-right">@avgDailySales</td>
<td class="text-right">@avgMonthlySales</td>
2018-05-22 10:11:50 +02:00
</tr>
<tr>
2024-01-19 02:36:36 +01:00
<th>@Model.PTData.Misc.Market</th>
2018-05-22 10:11:50 +02:00
<td class="text-right text-autocolor">@totalProfit.ToString("#,#0.00000000", new System.Globalization.CultureInfo("en-US"))</td>
2024-01-15 15:12:46 +01:00
<td class="text-right text-autocolor">@Math.Round(totalProfit / totalDays, 8).ToString("#,#0.00000000", new System.Globalization.CultureInfo("en-US"))</td>
<td class="text-right text-autocolor">@avgMonthlyProfit.ToString("#,#0.00000000", new System.Globalization.CultureInfo("en-US"))</td>
2018-05-22 10:11:50 +02:00
</tr>
2024-01-15 15:12:46 +01:00
@if(Model.PropertiesData.IsLeverageExchange)
{
<tr>
2024-01-19 00:11:16 +01:00
<th>Funding</th>
2024-01-15 15:12:46 +01:00
<td class="text-right text-autocolor">@Html.Raw(Math.Round(totalFundingFees,8).ToString("#0.00000000", new System.Globalization.CultureInfo("en-US")))</td>
<td class="text-right text-autocolor">@Html.Raw(Math.Round(totalFundingFees / totalDays,8).ToString("#,#0.00000000", new System.Globalization.CultureInfo("en-US")))</td>
<td class="text-right text-autocolor">@Html.Raw(Math.Round(totalFundingFees / totalMonths,8).ToString("#,#0.00000000", new System.Globalization.CultureInfo("en-US")))</td>
</tr>
}
<tr>
2024-01-19 00:11:16 +01:00
<th>@Model.PTData.Properties.Currency</th>
2024-01-15 15:12:46 +01:00
<td class="text-right text-autocolor">@Html.Raw(Math.Round(totalProfitFiat,0).ToString("#,#0", new System.Globalization.CultureInfo("en-US")))</td>
<td class="text-right text-autocolor">@Html.Raw(Math.Round(totalProfitFiat / totalDays, 0).ToString("#,#0", new System.Globalization.CultureInfo("en-US")))</td>
<td class="text-right text-autocolor">@Html.Raw(Math.Round(totalProfitFiat / totalMonths, 0).ToString("#,#0", new System.Globalization.CultureInfo("en-US")))</td>
</tr>
2024-01-16 17:56:52 +01:00
<tr>
2024-01-19 02:36:36 +01:00
<th>Gain</th>
<td class="text-right text-autocolor">@totalPercentGain.ToString("#,#0.00", new System.Globalization.CultureInfo("en-US")) %</td>
<td class="text-right text-autocolor">@avgDailyGain.ToString("#,#0.00", new System.Globalization.CultureInfo("en-US")) %</td>
<td class="text-right text-autocolor">@avgMonthlyGain.ToString("#,#0.00", new System.Globalization.CultureInfo("en-US")) %</td>
2024-01-16 17:56:52 +01:00
</tr>
2018-05-22 10:11:50 +02:00
</tbody>
</table>
</div>
</div>
<div class="col-md-6">
<div class="card-box">
@{
2024-01-16 17:56:52 +01:00
double estimatedBalance1Week = Math.Round(totalCurrentValue * Math.Pow((1 + (avgDailyGain / 100)), 7.0), 8);
double estimatedBalance1Month = Math.Round(totalCurrentValue * Math.Pow((1 + (avgDailyGain / 100)), 30.0), 8);
double estimatedBalance3Months = Math.Round(totalCurrentValue * Math.Pow((1 + (avgDailyGain / 100)), 90.0), 8);
double estimatedBalance6Months = Math.Round(totalCurrentValue * Math.Pow((1 + (avgDailyGain / 100)), 180.0), 8);
double estimatedBalance1Year = Math.Round(totalCurrentValue * Math.Pow((1 + (avgDailyGain / 100)), 365.0), 8);
2018-05-22 10:11:50 +02:00
}
2024-01-16 17:56:52 +01:00
<h4 class="m-t-0 header-title">TCV Prediction <small><i class="fa fa-info-circle text-muted" data-toggle="tooltip" data-placement="top" title="The balance prediction is based on your daily average gain of @avgDailyGain.ToString("#,#0.00", new System.Globalization.CultureInfo("en-US"))% and your current TCV of @totalCurrentValue.ToString("#,#0.00000000", new System.Globalization.CultureInfo("en-US"))"></i></small></h4>
2018-05-22 10:11:50 +02:00
<table class="table table-striped table-sm">
<thead>
<tr>
<th class="text-right"></th>
2024-01-19 02:36:36 +01:00
<th class="text-right">@Model.PTData.Misc.Market</th>
<th class="text-right">@Model.PTData.Properties.Currency</th>
<th class="text-right">Gain</th>
2018-05-22 10:11:50 +02:00
</tr>
</thead>
<tbody>
<tr>
2024-01-16 17:56:52 +01:00
<th>1 Week</th>
<td class="text-right text-autocolor">@estimatedBalance1Week.ToString("#,#0.00000000", new System.Globalization.CultureInfo("en-US"))</td>
<td class="text-right text-autocolor">@Html.Raw(Math.Round(estimatedBalance1Week * Model.MiscData.FiatConversionRate, 0).ToString("#,#0", new System.Globalization.CultureInfo("en-US")))</td>
2024-01-19 02:36:36 +01:00
<td class="text-right text-autocolor">@Math.Round((estimatedBalance1Week - totalCurrentValue) / totalCurrentValue * 100, 2).ToString("#,#0.00", new System.Globalization.CultureInfo("en-US")) %</td>
2024-01-16 17:56:52 +01:00
</tr>
<tr>
<th>1 Month</th>
2018-05-22 10:11:50 +02:00
<td class="text-right text-autocolor">@estimatedBalance1Month.ToString("#,#0.00000000", new System.Globalization.CultureInfo("en-US"))</td>
2024-01-15 15:12:46 +01:00
<td class="text-right text-autocolor">@Html.Raw(Math.Round(estimatedBalance1Month * Model.MiscData.FiatConversionRate, 0).ToString("#,#0", new System.Globalization.CultureInfo("en-US")))</td>
2024-01-19 02:36:36 +01:00
<td class="text-right text-autocolor">@Math.Round((estimatedBalance1Month - totalCurrentValue) / totalCurrentValue * 100, 2).ToString("#,#0.00", new System.Globalization.CultureInfo("en-US")) %</td>
2018-05-22 10:11:50 +02:00
</tr>
<tr>
2024-01-16 17:56:52 +01:00
<th>3 Months</th>
2018-05-22 10:11:50 +02:00
<td class="text-right text-autocolor">@estimatedBalance3Months.ToString("#,#0.00000000", new System.Globalization.CultureInfo("en-US"))</td>
2024-01-15 15:12:46 +01:00
<td class="text-right text-autocolor">@Html.Raw(Math.Round(estimatedBalance3Months * Model.MiscData.FiatConversionRate, 0).ToString("#,#0", new System.Globalization.CultureInfo("en-US")))</td>
2024-01-19 02:36:36 +01:00
<td class="text-right text-autocolor">@Math.Round((estimatedBalance3Months - totalCurrentValue) / totalCurrentValue * 100, 2).ToString("#,#0.00", new System.Globalization.CultureInfo("en-US")) %</td>
2018-05-22 10:11:50 +02:00
</tr>
<tr>
2024-01-16 17:56:52 +01:00
<th>6 Months</th>
2018-05-22 10:11:50 +02:00
<td class="text-right text-autocolor">@estimatedBalance6Months.ToString("#,#0.00000000", new System.Globalization.CultureInfo("en-US"))</td>
2024-01-15 15:12:46 +01:00
<td class="text-right text-autocolor">@Html.Raw(Math.Round(estimatedBalance6Months * Model.MiscData.FiatConversionRate, 0).ToString("#,#0", new System.Globalization.CultureInfo("en-US")))</td>
2024-01-19 02:36:36 +01:00
<td class="text-right text-autocolor">@Math.Round((estimatedBalance6Months - totalCurrentValue) / totalCurrentValue * 100, 2).ToString("#,#0.00", new System.Globalization.CultureInfo("en-US")) %</td>
2018-05-22 10:11:50 +02:00
</tr>
<tr>
2024-01-16 17:56:52 +01:00
<th>1 Year</th>
2018-05-22 10:11:50 +02:00
<td class="text-right text-autocolor">@estimatedBalance1Year.ToString("#,#0.00000000", new System.Globalization.CultureInfo("en-US"))</td>
2024-01-15 15:12:46 +01:00
<td class="text-right text-autocolor">@Html.Raw(Math.Round(estimatedBalance1Year * Model.MiscData.FiatConversionRate, 0).ToString("#,#0", new System.Globalization.CultureInfo("en-US")))</td>
2024-01-19 02:36:36 +01:00
<td class="text-right text-autocolor">@Math.Round((estimatedBalance1Year - totalCurrentValue) / totalCurrentValue * 100, 2).ToString("#,#0.00", new System.Globalization.CultureInfo("en-US")) %</td>
2018-05-22 10:11:50 +02:00
</tr>
</tbody>
</table>
</div>
</div>
</div>
2024-01-19 02:36:36 +01:00
2018-05-22 10:11:50 +02:00
<div class="row">
<div class="col-md-6">
2024-01-17 18:13:09 +01:00
<div class="card-box">
2024-01-19 00:11:16 +01:00
@{
var maxDays = Math.Min(Model.DailyStats.Count, Math.Min(Model.PTMagicConfiguration.GeneralSettings.Monitor.MaxDailySummaries, 30));
}
<h4 class="m-t-0 header-title">Last @maxDays Days</h4>
<table class="table table-sm">
2024-01-17 18:13:09 +01:00
<thead>
<tr>
2024-01-19 00:11:16 +01:00
<th>Day</th>
<th class="text-right">Buys</th>
<th class="text-right">Sales</th>
<th class="text-right">Profit @Model.Summary.MainMarket</th>
<th class="text-right">Profit @Model.PTData.Properties.Currency</th>
2024-01-19 02:36:36 +01:00
<th class="text-right">Gain</th>
2024-01-17 18:13:09 +01:00
</tr>
</thead>
<tbody>
@{
2024-01-19 00:11:16 +01:00
for (int i = 0; i < maxDays; i++)
2024-01-17 18:13:09 +01:00
{
2024-01-19 00:11:16 +01:00
DateTime salesDate = DateTime.ParseExact(Model.PTData.DailyStats[i].Date, "d-M-yyyy", CultureInfo.InvariantCulture);
var buys = Model.PTData.DailyStats[i].TotalBuys;
var sales = Model.PTData.DailyStats[i].TotalSales;
var profit = Model.PTData.DailyStats[i].TotalProfit;
var avgProfit = Model.PTData.DailyStats[i].AvgProfit;
var profitFiat = Math.Round(profit * Model.PTData.Misc.FiatConversionRate, 0);
2024-01-17 18:13:09 +01:00
<tr>
2024-01-19 00:11:16 +01:00
<td>@salesDate.ToString("yyyy-MM-dd")</td>
<td class="text-right text-autocolor"">@buys</td>
<td class="text-right text-autocolor"">@sales</td>
<td class="text-right text-autocolor">@profit.ToString("#,#0.00000000", new System.Globalization.CultureInfo("en-US"))</td>
<td class="text-right text-autocolor">@Math.Round(profitFiat,0).ToString("#,#0", new System.Globalization.CultureInfo("en-US"))</td>
2024-01-19 02:36:36 +01:00
<td class="text-right text-autocolor">@avgProfit.ToString("#,#0.00", new System.Globalization.CultureInfo("en-US")) %</td>
2024-01-17 18:13:09 +01:00
</tr>
}
}
</tbody>
</table>
</div>
</div>
2018-05-22 10:11:50 +02:00
2024-01-19 02:36:36 +01:00
<div class="col-md-6">
2018-05-22 10:11:50 +02:00
<div class="card-box">
2024-01-19 00:11:16 +01:00
@{
var maxMonths = Math.Min(Model.PTMagicConfiguration.GeneralSettings.Monitor.MaxMonthlySummaries, Model.MonthlyStats.Count);
}
<h4 class="m-t-0 header-title">Last @maxMonths months</h4>
2018-05-22 10:11:50 +02:00
<table class="table table-sm">
<thead>
<tr>
2024-01-19 00:11:16 +01:00
<th>Month</th>
2018-05-22 10:11:50 +02:00
<th class="text-right">Sales</th>
<th class="text-right">Profit @Model.Summary.MainMarket</th>
2024-01-19 00:11:16 +01:00
<th class="text-right">Profit @Model.PTData.Properties.Currency</th>
2024-01-19 02:36:36 +01:00
<th class="text-right">Growth</th>
2018-05-22 10:11:50 +02:00
</tr>
</thead>
<tbody>
2024-01-19 00:11:16 +01:00
@{
for (int i = 0; i < maxMonths; i++)
{
DateTime monthDate = DateTime.ParseExact(Model.PTData.MonthlyStats[i].Month, "M-yyyy", CultureInfo.InvariantCulture);
2024-01-19 02:36:36 +01:00
string monthName = monthDate.ToString("MMMM", CultureInfo.InvariantCulture);
2024-01-19 00:11:16 +01:00
var sales = Model.PTData.MonthlyStats[i].TotalSales;
var profit = Model.PTData.MonthlyStats[i].TotalProfitCurrency;
var profitFiat = Math.Round(profit * Model.PTData.Misc.FiatConversionRate, 0);
2024-01-19 02:36:36 +01:00
var growth = Math.Round(Model.PTData.MonthlyStats[i].AvgGrowth,2);
2018-05-22 10:11:50 +02:00
<tr>
2024-01-19 00:11:16 +01:00
<td>@monthName</td>
<td class="text-right text-autocolor">@sales</td>
<td class="text-right text-autocolor">@profit.ToString("#,#0.00000000", new System.Globalization.CultureInfo("en-US"))</td>
<td class="text-right text-autocolor">@profitFiat</td>
<td class="text-right text-autocolor">@growth %</td>
2018-05-22 10:11:50 +02:00
</tr>
2024-01-19 00:11:16 +01:00
}
2018-05-22 10:11:50 +02:00
}
</tbody>
</table>
2024-01-19 02:36:36 +01:00
</div
</div>
2018-05-22 10:11:50 +02:00
2024-01-19 02:36:36 +01:00
@* <div class="col-md-6"> *@
2018-05-22 10:11:50 +02:00
<div class="card-box">
2024-01-19 00:11:16 +01:00
<h4 class="m-t-0 header-title"><b>Top @Model.PTMagicConfiguration.GeneralSettings.Monitor.MaxTopMarkets Sales Markets</b></h4>
<table class="tablesaw table m-b-0" data-tablesaw-sortable data-tablesaw-sortable-switch>
2018-05-22 10:11:50 +02:00
<thead>
<tr>
2024-01-19 00:11:16 +01:00
<th scope="col" data-tablesaw-priority="persist" data-tablesaw-sortable-col data-tablesaw-sortable-default-col>Rank</th>
<th scope="col" data-tablesaw-sortable-col>Market</th>
<th scope="col" class="text-right" data-tablesaw-sortable-col>Profit @Model.PTData.Misc.Market</th>
<th scope="col" class="text-right" data-tablesaw-sortable-col>Sales</th>
<th scope="col" class="text-right" data-tablesaw-sortable-col>Avg/Trade</th>
2018-05-22 10:11:50 +02:00
</tr>
</thead>
<tbody>
@{
2024-01-19 00:11:16 +01:00
int rank = 1;
foreach (var pair in Model.ProfitablePairs)
{
string coin = pair.Coin;
double profit = Math.Round(pair.ProfitCurrency,8);
int sales = pair.SoldTimes;
double avg = Math.Round(pair.Avg,8);
double profitFiat = Math.Round(profit * Model.MiscData.FiatConversionRate, 0);
<tr>
<td>@rank</td>
<td><a href="@Core.Helper.SystemHelper.GetMarketLink(Model.PTMagicConfiguration.GeneralSettings.Monitor.LinkPlatform, Model.PTMagicConfiguration.GeneralSettings.Application.Exchange, coin, Model.PTData.Misc.Market, Model.PTMagicConfiguration.GeneralSettings.Monitor.TVCustomLayout)" target="_blank">@coin</a></td>
2024-01-19 00:11:16 +01:00
<td class="text-right text-autocolor-saw">@profit</td>
<td class="text-right">@sales</td>
<td class="text-right text-autocolor-saw">@avg </td>
</tr>
rank++;
2018-05-22 10:11:50 +02:00
}
}
</tbody>
</table>
</div>
2024-01-19 02:36:36 +01:00
@* </div> *@
2018-05-22 10:11:50 +02:00
2024-01-19 02:36:36 +01:00
</div>
2018-05-22 10:11:50 +02:00
}
@section Scripts {
<script src="@Html.Raw(Model.PTMagicConfiguration.GeneralSettings.Monitor.RootUrl)assets/plugins/tablesaw/js/tablesaw.js"></script>
<script src="@Html.Raw(Model.PTMagicConfiguration.GeneralSettings.Monitor.RootUrl)assets/plugins/d3/d3.min.js"></script>
<script src="@Html.Raw(Model.PTMagicConfiguration.GeneralSettings.Monitor.RootUrl)assets/plugins/nvd3/nv.d3.min.js"></script>
<script src="@Html.Raw(Model.PTMagicConfiguration.GeneralSettings.Monitor.RootUrl)assets/plugins/tablesaw/js/tablesaw-init.js"></script>
<!-- Required datatable js -->
<script src="@Html.Raw(Model.PTMagicConfiguration.GeneralSettings.Monitor.RootUrl)assets/plugins/datatables/jquery.dataTables.min.js"></script>
<script src="@Html.Raw(Model.PTMagicConfiguration.GeneralSettings.Monitor.RootUrl)assets/plugins/datatables/dataTables.bootstrap4.min.js"></script>
<!-- Buttons examples -->
<script src="@Html.Raw(Model.PTMagicConfiguration.GeneralSettings.Monitor.RootUrl)assets/plugins/datatables/dataTables.buttons.min.js"></script>
<script src="@Html.Raw(Model.PTMagicConfiguration.GeneralSettings.Monitor.RootUrl)assets/plugins/datatables/buttons.bootstrap4.min.js"></script>
<script src="@Html.Raw(Model.PTMagicConfiguration.GeneralSettings.Monitor.RootUrl)assets/plugins/datatables/jszip.min.js"></script>
<script src="@Html.Raw(Model.PTMagicConfiguration.GeneralSettings.Monitor.RootUrl)assets/plugins/datatables/pdfmake.min.js"></script>
<script src="@Html.Raw(Model.PTMagicConfiguration.GeneralSettings.Monitor.RootUrl)assets/plugins/datatables/vfs_fonts.js"></script>
<script src="@Html.Raw(Model.PTMagicConfiguration.GeneralSettings.Monitor.RootUrl)assets/plugins/datatables/buttons.html5.min.js"></script>
<script src="@Html.Raw(Model.PTMagicConfiguration.GeneralSettings.Monitor.RootUrl)assets/plugins/datatables/buttons.print.min.js"></script>
<script src="@Html.Raw(Model.PTMagicConfiguration.GeneralSettings.Monitor.RootUrl)assets/plugins/datatables/buttons.colVis.min.js"></script>
2024-01-19 00:11:16 +01:00
2018-05-22 10:11:50 +02:00
<script type="text/javascript">
(function ($) {
'use strict';
2024-01-19 00:11:16 +01:00
$('[role="tooltip"]').remove();
$('[data-toggle="tooltip"]').tooltip();
$('.text-autocolor').autocolor(false);
var salesChart; // Keep a reference to the chart
var salesData; // Keep a reference to the data
@if (!Model.SalesChartDataJSON.Equals("")) {
<text>
nv.addGraph(function () {
2024-01-21 07:59:24 +01:00
salesChart = nv.models.multiBarChart();
2024-01-19 00:11:16 +01:00
var height = 300;
2024-01-21 07:59:24 +01:00
salesChart.groupSpacing(0.5);
salesChart.showControls(false);
//salesChart.useInteractiveGuideline(true);
2024-01-19 00:11:16 +01:00
salesChart.xAxis.tickFormat(function (d) { return d3.time.format('%m/%d')(new Date(d)); });
salesChart.yAxis.axisLabel('').tickFormat(d3.format(',.2f'));
salesData = @Html.Raw(Model.SalesChartDataJSON);
d3.select('.sales-chart svg')
.datum(salesData)
.transition().duration(0)
.call(salesChart);
2024-01-30 10:48:36 +01:00
2024-01-19 00:11:16 +01:00
nv.utils.windowResize(salesChart.update);
return salesChart;
2018-05-22 10:11:50 +02:00
});
2024-01-19 00:11:16 +01:00
</text>
}
2018-05-22 10:11:50 +02:00
})(jQuery);
2024-01-19 00:11:16 +01:00
</script>
2024-01-16 17:56:52 +01:00
<script type="text/javascript">
(function ($) {
'use strict';
$('[role="tooltip"]').remove();
$('[data-toggle="tooltip"]').tooltip();
$('.text-autocolor').autocolor(false);
var cumulativeProfitChart; // Keep a reference to the chart
var cumulativeProfitData; // Keep a reference to the data
@if (!Model.CumulativeProfitChartDataJSON.Equals("")) {
<text>
nv.addGraph(function () {
cumulativeProfitChart = nv.models.lineChart();
var height = 300;
cumulativeProfitChart.useInteractiveGuideline(true);
cumulativeProfitChart.xAxis.tickFormat(function (d) { return d3.time.format('%m/%d')(new Date(d)); });
cumulativeProfitChart.yAxis.axisLabel('').tickFormat(d3.format(',.2f'));
2018-05-22 10:11:50 +02:00
2024-01-16 17:56:52 +01:00
cumulativeProfitData = @Html.Raw(Model.CumulativeProfitChartDataJSON);
2018-05-22 10:11:50 +02:00
2024-01-16 17:56:52 +01:00
d3.select('.cumulative-profit-chart svg')
.datum(cumulativeProfitData)
.transition().duration(0)
.call(cumulativeProfitChart);
2024-01-30 10:48:36 +01:00
2024-01-17 18:13:09 +01:00
nv.utils.windowResize(cumulativeProfitChart.update);
2024-01-16 17:56:52 +01:00
return cumulativeProfitChart;
});
</text>
}
})(jQuery);
2018-05-22 10:11:50 +02:00
</script>
2024-01-16 17:56:52 +01:00
<script type="text/javascript">
(function ($) {
'use strict';
$('[role="tooltip"]').remove();
$('[data-toggle="tooltip"]').tooltip();
$('.text-autocolor').autocolor(false);
var TCVChart; // Keep a reference to the chart
var TCVData; // Keep a reference to the data
@if (!Model.TCVChartDataJSON.Equals("")) {
<text>
nv.addGraph(function () {
TCVChart = nv.models.lineChart();
var height = 300;
TCVChart.useInteractiveGuideline(true);
TCVChart.xAxis.tickFormat(function (d) { return d3.time.format('%m/%d')(new Date(d)); });
TCVChart.yAxis.axisLabel('').tickFormat(d3.format(',.2f'));
TCVData = @Html.Raw(Model.TCVChartDataJSON);
d3.select('.TCV-chart svg')
.datum(TCVData)
.transition().duration(0)
.call(TCVChart);
2024-01-17 18:13:09 +01:00
nv.utils.windowResize(TCVChart.update);
2024-01-16 17:56:52 +01:00
return TCVChart;
});
</text>
}
})(jQuery);
</script>
<script type="text/javascript">
(function ($) {
'use strict';
$('[role="tooltip"]').remove();
$('[data-toggle="tooltip"]').tooltip();
$('.text-autocolor').autocolor(false);
var profitChart; // Keep a reference to the chart
var profitData; // Keep a reference to the data
@if (!Model.ProfitChartDataJSON.Equals("")) {
<text>
nv.addGraph(function () {
profitChart = nv.models.lineChart();
var height = 300;
profitChart.useInteractiveGuideline(true);
profitChart.xAxis.tickFormat(function (d) { return d3.time.format('%m/%d')(new Date(d)); });
profitChart.yAxis.axisLabel('').tickFormat(d3.format(',.2f'));
profitData = @Html.Raw(Model.ProfitChartDataJSON);
d3.select('.profit-chart svg')
.datum(profitData)
.transition().duration(0)
.call(profitChart);
2024-01-30 10:38:19 +01:00
profitChart.dispatch.on('renderEnd', function() {
// Get the chart's container
var container = d3.select('.profit-chart .nv-wrap.nv-lineChart .nv-linesWrap');
2024-02-01 12:25:04 +01:00
// Remove any existing y=0 line
container.selectAll('.zero-line').remove();
2024-01-30 10:38:19 +01:00
// Check if profitData[0].values is not empty
if (profitData[0].values.length > 0) {
// Get the x-values of the first and last data points
var xMin = profitChart.xAxis.scale()(profitData[0].values[0].x);
var xMax = profitChart.xAxis.scale()(profitData[0].values[profitData[0].values.length - 1].x);
// Add a line at y=0
container.insert('line', ':first-child')
2024-02-01 12:25:04 +01:00
.attr('class', 'zero-line') // Add a class to the line for easy selection
2024-01-30 10:38:19 +01:00
.attr('x1', xMin) // x position of the first end of the line
.attr('y1', profitChart.yAxis.scale()(0)) // y position of the first end of the line
.attr('x2', xMax) // x position of the second end of the line
.attr('y2', profitChart.yAxis.scale()(0)) // y position of the second end of the line
.attr('stroke', 'gray') // color of the line
.attr('stroke-width', 2); // width of the line
}
});
2024-01-17 18:13:09 +01:00
nv.utils.windowResize(profitChart.update);
2024-01-16 17:56:52 +01:00
return profitChart;
});
</text>
}
})(jQuery);
</script>
2024-01-30 10:48:36 +01:00
<script type="text/javascript">
function attachTooltipRemoval(chartClass) {
d3.selectAll(chartClass).on('mouseleave', function() {
var tooltip = d3.select(this).select('.nvtooltip');
if (!tooltip.empty()) {
tooltip.style('opacity', 0);
}
});
d3.selectAll(chartClass).on('mouseenter', function() {
var tooltip = d3.select(this).select('.nvtooltip');
if (!tooltip.empty()) {
tooltip.style('opacity', 1);
}
});
}
$(document).ready(function () {
// Hide all tooltips when the page is loaded
d3.selectAll('.nvtooltip').style('opacity', 0);
// Call the function for each chart
attachTooltipRemoval('.asset-distribution svg');
attachTooltipRemoval('.trend-chart svg');
attachTooltipRemoval('.profit-chart svg');
attachTooltipRemoval('.TCVLive-chart svg');
// Add other charts as needed
});
</script>
2018-05-22 10:11:50 +02:00
}