add paywall to download button
This commit is contained in:
parent
be62e9f6d6
commit
a0c8a3900a
@ -1708,7 +1708,7 @@
|
|||||||
{/await}
|
{/await}
|
||||||
</div>
|
</div>
|
||||||
</Lazy>
|
</Lazy>
|
||||||
|
<!--
|
||||||
<Lazy>
|
<Lazy>
|
||||||
<div
|
<div
|
||||||
class="w-full mt-10 sm:mt-5 m-auto sm:pl-6 sm:pb-6 sm:pt-6 {!$borrowedShareComponent
|
class="w-full mt-10 sm:mt-5 m-auto sm:pl-6 sm:pb-6 sm:pt-6 {!$borrowedShareComponent
|
||||||
@ -1720,7 +1720,8 @@
|
|||||||
{/await}
|
{/await}
|
||||||
</div>
|
</div>
|
||||||
</Lazy>
|
</Lazy>
|
||||||
|
-->
|
||||||
|
<!--
|
||||||
<Lazy>
|
<Lazy>
|
||||||
<div
|
<div
|
||||||
class="w-full mt-10 sm:mt-5 m-auto sm:pl-6 sm:pb-6 sm:pt-6 {!$marketMakerComponent
|
class="w-full mt-10 sm:mt-5 m-auto sm:pl-6 sm:pb-6 sm:pt-6 {!$marketMakerComponent
|
||||||
@ -1732,6 +1733,7 @@
|
|||||||
{/await}
|
{/await}
|
||||||
</div>
|
</div>
|
||||||
</Lazy>
|
</Lazy>
|
||||||
|
-->
|
||||||
|
|
||||||
<Lazy>
|
<Lazy>
|
||||||
<div
|
<div
|
||||||
|
|||||||
@ -8,6 +8,7 @@
|
|||||||
import * as DropdownMenu from "$lib/components/shadcn/dropdown-menu/index.js";
|
import * as DropdownMenu from "$lib/components/shadcn/dropdown-menu/index.js";
|
||||||
import { Button } from "$lib/components/shadcn/button/index.js";
|
import { Button } from "$lib/components/shadcn/button/index.js";
|
||||||
import { abbreviateNumber } from "$lib/utils";
|
import { abbreviateNumber } from "$lib/utils";
|
||||||
|
import { goto } from "$app/navigation";
|
||||||
//import * as XLSX from 'xlsx';
|
//import * as XLSX from 'xlsx';
|
||||||
|
|
||||||
import { init, use } from "echarts/core";
|
import { init, use } from "echarts/core";
|
||||||
@ -332,53 +333,54 @@
|
|||||||
};
|
};
|
||||||
|
|
||||||
const exportFundamentalData = (format = "csv") => {
|
const exportFundamentalData = (format = "csv") => {
|
||||||
const data = fullStatement;
|
if (data?.user?.tier === "Pro") {
|
||||||
if (!data || data.length === 0) {
|
const data = fullStatement;
|
||||||
return;
|
if (!data || data.length === 0) {
|
||||||
}
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
let properties = [
|
let properties = [
|
||||||
{
|
{
|
||||||
key: filterRule === "annual" ? "calendarYear" : "date",
|
key: filterRule === "annual" ? "calendarYear" : "date",
|
||||||
label: filterRule === "annual" ? "Year" : "Quarter",
|
label: filterRule === "annual" ? "Year" : "Quarter",
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
|
||||||
for (let i = 0; i < statementConfig?.length; i++) {
|
for (let i = 0; i < statementConfig?.length; i++) {
|
||||||
properties.push({
|
properties.push({
|
||||||
key: statementConfig[i]?.propertyName,
|
key: statementConfig[i]?.propertyName,
|
||||||
label: statementConfig[i]?.label,
|
label: statementConfig[i]?.label,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
// Helper function to handle special cases
|
// Helper function to handle special cases
|
||||||
|
|
||||||
// Create rows for CSV/Excel
|
// Create rows for CSV/Excel
|
||||||
let rows = data.map((item) =>
|
let rows = data.map((item) =>
|
||||||
properties?.map((property) => item[property?.key] || 0),
|
properties?.map((property) => item[property?.key] || 0),
|
||||||
);
|
);
|
||||||
|
|
||||||
// Include headers
|
// Include headers
|
||||||
const headers = properties.map((prop) => prop.label);
|
const headers = properties.map((prop) => prop.label);
|
||||||
rows.unshift(headers);
|
rows.unshift(headers);
|
||||||
|
|
||||||
// Check the format to export
|
// Check the format to export
|
||||||
if (format.toLowerCase() === "csv") {
|
if (format.toLowerCase() === "csv") {
|
||||||
const csvContent = rows?.map((row) => row.join(",")).join("\n");
|
const csvContent = rows.map((row) => row.join(",")).join("\n");
|
||||||
const blob = new Blob([csvContent], {
|
const blob = new Blob([csvContent], {
|
||||||
type: "data:text/csv;charset=utf-8",
|
type: "data:text/csv;charset=utf-8",
|
||||||
});
|
});
|
||||||
const url = URL.createObjectURL(blob);
|
const url = URL.createObjectURL(blob);
|
||||||
const a = document.createElement("a");
|
const a = document.createElement("a");
|
||||||
a.href = url;
|
a.href = url;
|
||||||
a.download =
|
a.download =
|
||||||
$stockTicker.toLowerCase() +
|
$stockTicker.toLowerCase() +
|
||||||
`${filterRule === "annual" ? "_annual" : "_quarter"}_balance_sheet_statement.csv`;
|
`${filterRule === "annual" ? "_annual" : "_quarter"}_cashflow_statement.csv`;
|
||||||
document.body.appendChild(a);
|
document.body.appendChild(a);
|
||||||
a.click();
|
a.click();
|
||||||
document.body.removeChild(a);
|
document.body.removeChild(a);
|
||||||
URL.revokeObjectURL(url);
|
URL.revokeObjectURL(url);
|
||||||
} /*else if (format.toLowerCase() === "excel") {
|
} /*else if (format.toLowerCase() === "excel") {
|
||||||
const worksheet = XLSX.utils.aoa_to_sheet(rows);
|
const worksheet = XLSX.utils.aoa_to_sheet(rows);
|
||||||
const workbook = XLSX.utils.book_new();
|
const workbook = XLSX.utils.book_new();
|
||||||
XLSX.utils.book_append_sheet(workbook, worksheet, "Ratios Statement");
|
XLSX.utils.book_append_sheet(workbook, worksheet, "Ratios Statement");
|
||||||
@ -389,6 +391,9 @@
|
|||||||
|
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
|
} else {
|
||||||
|
goto("/pricing");
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
$: {
|
$: {
|
||||||
@ -623,6 +628,17 @@
|
|||||||
class="ml-2 w-full border-gray-600 border bg-[#09090B] sm:hover:bg-[#27272A] ease-out flex flex-row justify-between items-center px-3 py-2 text-white rounded-lg truncate"
|
class="ml-2 w-full border-gray-600 border bg-[#09090B] sm:hover:bg-[#27272A] ease-out flex flex-row justify-between items-center px-3 py-2 text-white rounded-lg truncate"
|
||||||
>
|
>
|
||||||
<span class="truncate text-white">Download</span>
|
<span class="truncate text-white">Download</span>
|
||||||
|
<svg
|
||||||
|
class="{data?.user?.tier === 'Pro'
|
||||||
|
? 'hidden'
|
||||||
|
: ''} ml-1 -mt-0.5 w-3.5 h-3.5"
|
||||||
|
xmlns="http://www.w3.org/2000/svg"
|
||||||
|
viewBox="0 0 24 24"
|
||||||
|
><path
|
||||||
|
fill="#A3A3A3"
|
||||||
|
d="M17 9V7c0-2.8-2.2-5-5-5S7 4.2 7 7v2c-1.7 0-3 1.3-3 3v7c0 1.7 1.3 3 3 3h10c1.7 0 3-1.3 3-3v-7c0-1.7-1.3-3-3-3M9 7c0-1.7 1.3-3 3-3s3 1.3 3 3v2H9z"
|
||||||
|
/></svg
|
||||||
|
>
|
||||||
</Button>
|
</Button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@ -9,7 +9,7 @@
|
|||||||
import { Button } from "$lib/components/shadcn/button/index.js";
|
import { Button } from "$lib/components/shadcn/button/index.js";
|
||||||
//import * as XLSX from 'xlsx';
|
//import * as XLSX from 'xlsx';
|
||||||
import { Chart } from "svelte-echarts";
|
import { Chart } from "svelte-echarts";
|
||||||
|
import { goto } from "$app/navigation";
|
||||||
import { init, use } from "echarts/core";
|
import { init, use } from "echarts/core";
|
||||||
import { LineChart, BarChart } from "echarts/charts";
|
import { LineChart, BarChart } from "echarts/charts";
|
||||||
import { GridComponent, TooltipComponent } from "echarts/components";
|
import { GridComponent, TooltipComponent } from "echarts/components";
|
||||||
@ -278,53 +278,54 @@
|
|||||||
};
|
};
|
||||||
|
|
||||||
const exportFundamentalData = (format = "csv") => {
|
const exportFundamentalData = (format = "csv") => {
|
||||||
const data = fullStatement;
|
if (data?.user?.tier === "Pro") {
|
||||||
if (!data || data.length === 0) {
|
const data = fullStatement;
|
||||||
return;
|
if (!data || data.length === 0) {
|
||||||
}
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
let properties = [
|
let properties = [
|
||||||
{
|
{
|
||||||
key: filterRule === "annual" ? "calendarYear" : "date",
|
key: filterRule === "annual" ? "calendarYear" : "date",
|
||||||
label: filterRule === "annual" ? "Year" : "Quarter",
|
label: filterRule === "annual" ? "Year" : "Quarter",
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
|
||||||
for (let i = 0; i < statementConfig?.length; i++) {
|
for (let i = 0; i < statementConfig?.length; i++) {
|
||||||
properties.push({
|
properties.push({
|
||||||
key: statementConfig[i]?.propertyName,
|
key: statementConfig[i]?.propertyName,
|
||||||
label: statementConfig[i]?.label,
|
label: statementConfig[i]?.label,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
// Helper function to handle special cases
|
// Helper function to handle special cases
|
||||||
|
|
||||||
// Create rows for CSV/Excel
|
// Create rows for CSV/Excel
|
||||||
let rows = data.map((item) =>
|
let rows = data.map((item) =>
|
||||||
properties?.map((property) => item[property?.key] || 0),
|
properties?.map((property) => item[property?.key] || 0),
|
||||||
);
|
);
|
||||||
|
|
||||||
// Include headers
|
// Include headers
|
||||||
const headers = properties.map((prop) => prop.label);
|
const headers = properties.map((prop) => prop.label);
|
||||||
rows.unshift(headers);
|
rows.unshift(headers);
|
||||||
|
|
||||||
// Check the format to export
|
// Check the format to export
|
||||||
if (format.toLowerCase() === "csv") {
|
if (format.toLowerCase() === "csv") {
|
||||||
const csvContent = rows?.map((row) => row.join(",")).join("\n");
|
const csvContent = rows.map((row) => row.join(",")).join("\n");
|
||||||
const blob = new Blob([csvContent], {
|
const blob = new Blob([csvContent], {
|
||||||
type: "data:text/csv;charset=utf-8",
|
type: "data:text/csv;charset=utf-8",
|
||||||
});
|
});
|
||||||
const url = URL.createObjectURL(blob);
|
const url = URL.createObjectURL(blob);
|
||||||
const a = document.createElement("a");
|
const a = document.createElement("a");
|
||||||
a.href = url;
|
a.href = url;
|
||||||
a.download =
|
a.download =
|
||||||
$stockTicker.toLowerCase() +
|
$stockTicker.toLowerCase() +
|
||||||
`${filterRule === "annual" ? "_annual" : "_quarter"}_cashflow_statement.csv`;
|
`${filterRule === "annual" ? "_annual" : "_quarter"}_cashflow_statement.csv`;
|
||||||
document.body.appendChild(a);
|
document.body.appendChild(a);
|
||||||
a.click();
|
a.click();
|
||||||
document.body.removeChild(a);
|
document.body.removeChild(a);
|
||||||
URL.revokeObjectURL(url);
|
URL.revokeObjectURL(url);
|
||||||
} /*else if (format.toLowerCase() === "excel") {
|
} /*else if (format.toLowerCase() === "excel") {
|
||||||
const worksheet = XLSX.utils.aoa_to_sheet(rows);
|
const worksheet = XLSX.utils.aoa_to_sheet(rows);
|
||||||
const workbook = XLSX.utils.book_new();
|
const workbook = XLSX.utils.book_new();
|
||||||
XLSX.utils.book_append_sheet(workbook, worksheet, "Ratios Statement");
|
XLSX.utils.book_append_sheet(workbook, worksheet, "Ratios Statement");
|
||||||
@ -335,6 +336,9 @@
|
|||||||
|
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
|
} else {
|
||||||
|
goto("/pricing");
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
$: {
|
$: {
|
||||||
@ -567,6 +571,17 @@
|
|||||||
class="ml-2 w-full border-gray-600 border bg-[#09090B] sm:hover:bg-[#27272A] ease-out flex flex-row justify-between items-center px-3 py-2 text-white rounded-lg truncate"
|
class="ml-2 w-full border-gray-600 border bg-[#09090B] sm:hover:bg-[#27272A] ease-out flex flex-row justify-between items-center px-3 py-2 text-white rounded-lg truncate"
|
||||||
>
|
>
|
||||||
<span class="truncate text-white">Download</span>
|
<span class="truncate text-white">Download</span>
|
||||||
|
<svg
|
||||||
|
class="{data?.user?.tier === 'Pro'
|
||||||
|
? 'hidden'
|
||||||
|
: ''} ml-1 -mt-0.5 w-3.5 h-3.5"
|
||||||
|
xmlns="http://www.w3.org/2000/svg"
|
||||||
|
viewBox="0 0 24 24"
|
||||||
|
><path
|
||||||
|
fill="#A3A3A3"
|
||||||
|
d="M17 9V7c0-2.8-2.2-5-5-5S7 4.2 7 7v2c-1.7 0-3 1.3-3 3v7c0 1.7 1.3 3 3 3h10c1.7 0 3-1.3 3-3v-7c0-1.7-1.3-3-3-3M9 7c0-1.7 1.3-3 3-3s3 1.3 3 3v2H9z"
|
||||||
|
/></svg
|
||||||
|
>
|
||||||
</Button>
|
</Button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@ -6,6 +6,7 @@
|
|||||||
} from "$lib/store";
|
} from "$lib/store";
|
||||||
import * as DropdownMenu from "$lib/components/shadcn/dropdown-menu/index.js";
|
import * as DropdownMenu from "$lib/components/shadcn/dropdown-menu/index.js";
|
||||||
import { Button } from "$lib/components/shadcn/button/index.js";
|
import { Button } from "$lib/components/shadcn/button/index.js";
|
||||||
|
import { goto } from "$app/navigation";
|
||||||
import { Chart } from "svelte-echarts";
|
import { Chart } from "svelte-echarts";
|
||||||
import { init, use } from "echarts/core";
|
import { init, use } from "echarts/core";
|
||||||
import { BarChart } from "echarts/charts";
|
import { BarChart } from "echarts/charts";
|
||||||
@ -260,55 +261,59 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
const exportData = (format = "csv") => {
|
const exportData = (format = "csv") => {
|
||||||
// Add headers row
|
if (data?.user?.tier === "Pro") {
|
||||||
const csvRows = [];
|
// Add headers row
|
||||||
csvRows.push("Date,Employees,Change,Growth");
|
const csvRows = [];
|
||||||
|
csvRows.push("Date,Employees,Change,Growth");
|
||||||
|
|
||||||
// Add data rows
|
// Add data rows
|
||||||
historyList.forEach((item, index) => {
|
historyList.forEach((item, index) => {
|
||||||
const date = new Date(item.filingDate).toLocaleString("en-US", {
|
const date = new Date(item.filingDate).toLocaleString("en-US", {
|
||||||
month: "short",
|
month: "short",
|
||||||
day: "numeric",
|
day: "numeric",
|
||||||
year: "numeric",
|
year: "numeric",
|
||||||
|
});
|
||||||
|
|
||||||
|
const employees = item.employeeCount;
|
||||||
|
|
||||||
|
// Calculate change
|
||||||
|
const change =
|
||||||
|
index + 1 < historyList.length
|
||||||
|
? item.employeeCount - historyList[index + 1].employeeCount
|
||||||
|
: 0;
|
||||||
|
|
||||||
|
// Calculate growth percentage
|
||||||
|
let growth = "0.00%";
|
||||||
|
if (index + 1 < historyList.length) {
|
||||||
|
const growthValue =
|
||||||
|
((item.employeeCount - historyList[index + 1].employeeCount) /
|
||||||
|
item.employeeCount) *
|
||||||
|
100;
|
||||||
|
if (growthValue > 0) {
|
||||||
|
growth = `+${growthValue.toFixed(2)}%`;
|
||||||
|
} else if (growthValue < 0) {
|
||||||
|
growth = `-${Math.abs(growthValue).toFixed(2)}%`;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const csvRow = `${date},${employees},${change},${growth}`;
|
||||||
|
csvRows.push(csvRow);
|
||||||
});
|
});
|
||||||
|
|
||||||
const employees = item.employeeCount;
|
// Create CSV blob and trigger download
|
||||||
|
const csv = csvRows.join("\n");
|
||||||
// Calculate change
|
const blob = new Blob([csv], { type: "text/csv" });
|
||||||
const change =
|
const url = window.URL.createObjectURL(blob);
|
||||||
index + 1 < historyList.length
|
const a = document.createElement("a");
|
||||||
? item.employeeCount - historyList[index + 1].employeeCount
|
a.setAttribute("hidden", "");
|
||||||
: 0;
|
a.setAttribute("href", url);
|
||||||
|
a.setAttribute("download", `${$stockTicker}_employees.csv`);
|
||||||
// Calculate growth percentage
|
document.body.appendChild(a);
|
||||||
let growth = "0.00%";
|
a.click();
|
||||||
if (index + 1 < historyList.length) {
|
document.body.removeChild(a);
|
||||||
const growthValue =
|
} else {
|
||||||
((item.employeeCount - historyList[index + 1].employeeCount) /
|
goto("/pricing");
|
||||||
item.employeeCount) *
|
}
|
||||||
100;
|
|
||||||
if (growthValue > 0) {
|
|
||||||
growth = `+${growthValue.toFixed(2)}%`;
|
|
||||||
} else if (growthValue < 0) {
|
|
||||||
growth = `-${Math.abs(growthValue).toFixed(2)}%`;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
const csvRow = `${date},${employees},${change},${growth}`;
|
|
||||||
csvRows.push(csvRow);
|
|
||||||
});
|
|
||||||
|
|
||||||
// Create CSV blob and trigger download
|
|
||||||
const csv = csvRows.join("\n");
|
|
||||||
const blob = new Blob([csv], { type: "text/csv" });
|
|
||||||
const url = window.URL.createObjectURL(blob);
|
|
||||||
const a = document.createElement("a");
|
|
||||||
a.setAttribute("hidden", "");
|
|
||||||
a.setAttribute("href", url);
|
|
||||||
a.setAttribute("download", `${$stockTicker}_employees.csv`);
|
|
||||||
document.body.appendChild(a);
|
|
||||||
a.click();
|
|
||||||
document.body.removeChild(a);
|
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
@ -546,6 +551,17 @@
|
|||||||
class="ml-2 w-full border-gray-600 border bg-[#09090B] sm:hover:bg-[#27272A] ease-out flex flex-row justify-between items-center px-3 py-2 text-white rounded-lg truncate"
|
class="ml-2 w-full border-gray-600 border bg-[#09090B] sm:hover:bg-[#27272A] ease-out flex flex-row justify-between items-center px-3 py-2 text-white rounded-lg truncate"
|
||||||
>
|
>
|
||||||
<span class="truncate text-white">Download</span>
|
<span class="truncate text-white">Download</span>
|
||||||
|
<svg
|
||||||
|
class="{data?.user?.tier === 'Pro'
|
||||||
|
? 'hidden'
|
||||||
|
: ''} ml-1 -mt-0.5 w-3.5 h-3.5"
|
||||||
|
xmlns="http://www.w3.org/2000/svg"
|
||||||
|
viewBox="0 0 24 24"
|
||||||
|
><path
|
||||||
|
fill="#A3A3A3"
|
||||||
|
d="M17 9V7c0-2.8-2.2-5-5-5S7 4.2 7 7v2c-1.7 0-3 1.3-3 3v7c0 1.7 1.3 3 3 3h10c1.7 0 3-1.3 3-3v-7c0-1.7-1.3-3-3-3M9 7c0-1.7 1.3-3 3-3s3 1.3 3 3v2H9z"
|
||||||
|
/></svg
|
||||||
|
>
|
||||||
</Button>
|
</Button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@ -9,7 +9,7 @@
|
|||||||
import { Button } from "$lib/components/shadcn/button/index.js";
|
import { Button } from "$lib/components/shadcn/button/index.js";
|
||||||
//import * as XLSX from 'xlsx';
|
//import * as XLSX from 'xlsx';
|
||||||
import { Chart } from "svelte-echarts";
|
import { Chart } from "svelte-echarts";
|
||||||
|
import { goto } from "$app/navigation";
|
||||||
import { init, use } from "echarts/core";
|
import { init, use } from "echarts/core";
|
||||||
import { LineChart, BarChart } from "echarts/charts";
|
import { LineChart, BarChart } from "echarts/charts";
|
||||||
import { GridComponent, TooltipComponent } from "echarts/components";
|
import { GridComponent, TooltipComponent } from "echarts/components";
|
||||||
@ -258,53 +258,54 @@
|
|||||||
displayStatement = "revenue";
|
displayStatement = "revenue";
|
||||||
|
|
||||||
const exportFundamentalData = (format = "csv") => {
|
const exportFundamentalData = (format = "csv") => {
|
||||||
const data = fullStatement;
|
if (data?.user?.tier === "Pro") {
|
||||||
if (!data || data.length === 0) {
|
const data = fullStatement;
|
||||||
return;
|
if (!data || data.length === 0) {
|
||||||
}
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
let properties = [
|
let properties = [
|
||||||
{
|
{
|
||||||
key: filterRule === "annual" ? "calendarYear" : "date",
|
key: filterRule === "annual" ? "calendarYear" : "date",
|
||||||
label: filterRule === "annual" ? "Year" : "Quarter",
|
label: filterRule === "annual" ? "Year" : "Quarter",
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
|
||||||
for (let i = 0; i < statementConfig?.length; i++) {
|
for (let i = 0; i < statementConfig?.length; i++) {
|
||||||
properties.push({
|
properties.push({
|
||||||
key: statementConfig[i]?.propertyName,
|
key: statementConfig[i]?.propertyName,
|
||||||
label: statementConfig[i]?.label,
|
label: statementConfig[i]?.label,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
// Helper function to handle special cases
|
// Helper function to handle special cases
|
||||||
|
|
||||||
// Create rows for CSV/Excel
|
// Create rows for CSV/Excel
|
||||||
let rows = data.map((item) =>
|
let rows = data.map((item) =>
|
||||||
properties?.map((property) => item[property?.key] || 0),
|
properties?.map((property) => item[property?.key] || 0),
|
||||||
);
|
);
|
||||||
|
|
||||||
// Include headers
|
// Include headers
|
||||||
const headers = properties.map((prop) => prop.label);
|
const headers = properties.map((prop) => prop.label);
|
||||||
rows.unshift(headers);
|
rows.unshift(headers);
|
||||||
|
|
||||||
// Check the format to export
|
// Check the format to export
|
||||||
if (format.toLowerCase() === "csv") {
|
if (format.toLowerCase() === "csv") {
|
||||||
const csvContent = rows.map((row) => row.join(",")).join("\n");
|
const csvContent = rows.map((row) => row.join(",")).join("\n");
|
||||||
const blob = new Blob([csvContent], {
|
const blob = new Blob([csvContent], {
|
||||||
type: "data:text/csv;charset=utf-8",
|
type: "data:text/csv;charset=utf-8",
|
||||||
});
|
});
|
||||||
const url = URL.createObjectURL(blob);
|
const url = URL.createObjectURL(blob);
|
||||||
const a = document.createElement("a");
|
const a = document.createElement("a");
|
||||||
a.href = url;
|
a.href = url;
|
||||||
a.download =
|
a.download =
|
||||||
$stockTicker.toLowerCase() +
|
$stockTicker.toLowerCase() +
|
||||||
`${filterRule === "annual" ? "_annual" : "_quarter"}_income_statement.csv`;
|
`${filterRule === "annual" ? "_annual" : "_quarter"}_income_statement.csv`;
|
||||||
document.body.appendChild(a);
|
document.body.appendChild(a);
|
||||||
a.click();
|
a.click();
|
||||||
document.body.removeChild(a);
|
document.body.removeChild(a);
|
||||||
URL.revokeObjectURL(url);
|
URL.revokeObjectURL(url);
|
||||||
} /*else if (format.toLowerCase() === "excel") {
|
} /*else if (format.toLowerCase() === "excel") {
|
||||||
const worksheet = XLSX.utils.aoa_to_sheet(rows);
|
const worksheet = XLSX.utils.aoa_to_sheet(rows);
|
||||||
const workbook = XLSX.utils.book_new();
|
const workbook = XLSX.utils.book_new();
|
||||||
XLSX.utils.book_append_sheet(workbook, worksheet, "Ratios Statement");
|
XLSX.utils.book_append_sheet(workbook, worksheet, "Ratios Statement");
|
||||||
@ -315,6 +316,9 @@
|
|||||||
|
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
|
} else {
|
||||||
|
goto("/pricing");
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
$: {
|
$: {
|
||||||
@ -548,6 +552,17 @@
|
|||||||
class="ml-2 w-full border-gray-600 border bg-[#09090B] sm:hover:bg-[#27272A] ease-out flex flex-row justify-between items-center px-3 py-2 text-white rounded-lg truncate"
|
class="ml-2 w-full border-gray-600 border bg-[#09090B] sm:hover:bg-[#27272A] ease-out flex flex-row justify-between items-center px-3 py-2 text-white rounded-lg truncate"
|
||||||
>
|
>
|
||||||
<span class="truncate text-white">Download</span>
|
<span class="truncate text-white">Download</span>
|
||||||
|
<svg
|
||||||
|
class="{data?.user?.tier === 'Pro'
|
||||||
|
? 'hidden'
|
||||||
|
: ''} ml-1 -mt-0.5 w-3.5 h-3.5"
|
||||||
|
xmlns="http://www.w3.org/2000/svg"
|
||||||
|
viewBox="0 0 24 24"
|
||||||
|
><path
|
||||||
|
fill="#A3A3A3"
|
||||||
|
d="M17 9V7c0-2.8-2.2-5-5-5S7 4.2 7 7v2c-1.7 0-3 1.3-3 3v7c0 1.7 1.3 3 3 3h10c1.7 0 3-1.3 3-3v-7c0-1.7-1.3-3-3-3M9 7c0-1.7 1.3-3 3-3s3 1.3 3 3v2H9z"
|
||||||
|
/></svg
|
||||||
|
>
|
||||||
</Button>
|
</Button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@ -8,6 +8,7 @@
|
|||||||
import * as DropdownMenu from "$lib/components/shadcn/dropdown-menu/index.js";
|
import * as DropdownMenu from "$lib/components/shadcn/dropdown-menu/index.js";
|
||||||
import { Button } from "$lib/components/shadcn/button/index.js";
|
import { Button } from "$lib/components/shadcn/button/index.js";
|
||||||
//import * as XLSX from 'xlsx';
|
//import * as XLSX from 'xlsx';
|
||||||
|
import { goto } from "$app/navigation";
|
||||||
import { Chart } from "svelte-echarts";
|
import { Chart } from "svelte-echarts";
|
||||||
|
|
||||||
import { init, use } from "echarts/core";
|
import { init, use } from "echarts/core";
|
||||||
@ -242,50 +243,54 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
const exportData = (format = "csv") => {
|
const exportData = (format = "csv") => {
|
||||||
// Add headers row
|
if (data?.user?.tier === "Pro") {
|
||||||
const csvRows = [];
|
// Add headers row
|
||||||
|
const csvRows = [];
|
||||||
|
|
||||||
csvRows.push("Date,Market Cap,Growth");
|
csvRows.push("Date,Market Cap,Growth");
|
||||||
|
|
||||||
// Add data rows
|
// Add data rows
|
||||||
tableList?.forEach((item, index) => {
|
tableList?.forEach((item, index) => {
|
||||||
const date = item.date;
|
const date = item.date;
|
||||||
const marketCap = item.marketCap;
|
const marketCap = item.marketCap;
|
||||||
|
|
||||||
// Calculate growth percentage
|
// Calculate growth percentage
|
||||||
let growth = "-";
|
let growth = "-";
|
||||||
if (index + 1 < tableList.length) {
|
if (index + 1 < tableList.length) {
|
||||||
if (item.marketCap - tableList[index + 1].marketCap > 0) {
|
if (item.marketCap - tableList[index + 1].marketCap > 0) {
|
||||||
growth = `+${(
|
growth = `+${(
|
||||||
((item.marketCap - tableList[index + 1].marketCap) /
|
((item.marketCap - tableList[index + 1].marketCap) /
|
||||||
item.marketCap) *
|
item.marketCap) *
|
||||||
100
|
100
|
||||||
).toFixed(2)}%`;
|
).toFixed(2)}%`;
|
||||||
} else if (item.marketCap - tableList[index + 1].marketCap < 0) {
|
} else if (item.marketCap - tableList[index + 1].marketCap < 0) {
|
||||||
growth = `-${(
|
growth = `-${(
|
||||||
Math.abs(
|
Math.abs(
|
||||||
(tableList[index + 1].marketCap - item.marketCap) /
|
(tableList[index + 1].marketCap - item.marketCap) /
|
||||||
item.marketCap,
|
item.marketCap,
|
||||||
) * 100
|
) * 100
|
||||||
).toFixed(2)}%`;
|
).toFixed(2)}%`;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
const csvRow = `${date},${marketCap},${growth}`;
|
const csvRow = `${date},${marketCap},${growth}`;
|
||||||
csvRows.push(csvRow);
|
csvRows.push(csvRow);
|
||||||
});
|
});
|
||||||
|
|
||||||
// Create CSV blob and trigger download
|
// Create CSV blob and trigger download
|
||||||
const csv = csvRows.join("\n");
|
const csv = csvRows.join("\n");
|
||||||
const blob = new Blob([csv], { type: "text/csv" });
|
const blob = new Blob([csv], { type: "text/csv" });
|
||||||
const url = window.URL.createObjectURL(blob);
|
const url = window.URL.createObjectURL(blob);
|
||||||
const a = document.createElement("a");
|
const a = document.createElement("a");
|
||||||
a.setAttribute("hidden", "");
|
a.setAttribute("hidden", "");
|
||||||
a.setAttribute("href", url);
|
a.setAttribute("href", url);
|
||||||
a.setAttribute("download", `${$stockTicker}_market_cap.csv`);
|
a.setAttribute("download", `${$stockTicker}_market_cap.csv`);
|
||||||
document.body.appendChild(a);
|
document.body.appendChild(a);
|
||||||
a.click();
|
a.click();
|
||||||
document.body.removeChild(a);
|
document.body.removeChild(a);
|
||||||
|
} else {
|
||||||
|
goto("/pricing");
|
||||||
|
}
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
@ -447,6 +452,17 @@
|
|||||||
class="ml-2 w-full border-gray-600 border bg-[#09090B] sm:hover:bg-[#27272A] ease-out flex flex-row justify-between items-center px-3 py-2 text-white rounded-lg truncate"
|
class="ml-2 w-full border-gray-600 border bg-[#09090B] sm:hover:bg-[#27272A] ease-out flex flex-row justify-between items-center px-3 py-2 text-white rounded-lg truncate"
|
||||||
>
|
>
|
||||||
<span class="truncate text-white">Download</span>
|
<span class="truncate text-white">Download</span>
|
||||||
|
<svg
|
||||||
|
class="{data?.user?.tier === 'Pro'
|
||||||
|
? 'hidden'
|
||||||
|
: ''} ml-1 -mt-0.5 w-3.5 h-3.5"
|
||||||
|
xmlns="http://www.w3.org/2000/svg"
|
||||||
|
viewBox="0 0 24 24"
|
||||||
|
><path
|
||||||
|
fill="#A3A3A3"
|
||||||
|
d="M17 9V7c0-2.8-2.2-5-5-5S7 4.2 7 7v2c-1.7 0-3 1.3-3 3v7c0 1.7 1.3 3 3 3h10c1.7 0 3-1.3 3-3v-7c0-1.7-1.3-3-3-3M9 7c0-1.7 1.3-3 3-3s3 1.3 3 3v2H9z"
|
||||||
|
/></svg
|
||||||
|
>
|
||||||
</Button>
|
</Button>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|||||||
@ -9,6 +9,7 @@
|
|||||||
import * as DropdownMenu from "$lib/components/shadcn/dropdown-menu/index.js";
|
import * as DropdownMenu from "$lib/components/shadcn/dropdown-menu/index.js";
|
||||||
import { Button } from "$lib/components/shadcn/button/index.js";
|
import { Button } from "$lib/components/shadcn/button/index.js";
|
||||||
//import * as XLSX from 'xlsx';
|
//import * as XLSX from 'xlsx';
|
||||||
|
import { goto } from "$app/navigation";
|
||||||
import { init, use } from "echarts/core";
|
import { init, use } from "echarts/core";
|
||||||
import { LineChart, BarChart } from "echarts/charts";
|
import { LineChart, BarChart } from "echarts/charts";
|
||||||
import { GridComponent, TooltipComponent } from "echarts/components";
|
import { GridComponent, TooltipComponent } from "echarts/components";
|
||||||
@ -217,53 +218,54 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
const exportFundamentalData = (format = "csv") => {
|
const exportFundamentalData = (format = "csv") => {
|
||||||
const data = fullStatement;
|
if (data?.user?.tier === "Pro") {
|
||||||
if (!data || data.length === 0) {
|
const data = fullStatement;
|
||||||
return;
|
if (!data || data.length === 0) {
|
||||||
}
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
let properties = [
|
let properties = [
|
||||||
{
|
{
|
||||||
key: filterRule === "annual" ? "calendarYear" : "date",
|
key: filterRule === "annual" ? "calendarYear" : "date",
|
||||||
label: filterRule === "annual" ? "Year" : "Quarter",
|
label: filterRule === "annual" ? "Year" : "Quarter",
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
|
||||||
for (let i = 0; i < statementConfig?.length; i++) {
|
for (let i = 0; i < statementConfig?.length; i++) {
|
||||||
properties.push({
|
properties.push({
|
||||||
key: statementConfig[i]?.propertyName,
|
key: statementConfig[i]?.propertyName,
|
||||||
label: statementConfig[i]?.label,
|
label: statementConfig[i]?.label,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
// Helper function to handle special cases
|
// Helper function to handle special cases
|
||||||
|
|
||||||
// Create rows for CSV/Excel
|
// Create rows for CSV/Excel
|
||||||
let rows = data.map((item) =>
|
let rows = data.map((item) =>
|
||||||
properties?.map((property) => item[property?.key] || 0),
|
properties?.map((property) => item[property?.key] || 0),
|
||||||
);
|
);
|
||||||
|
|
||||||
// Include headers
|
// Include headers
|
||||||
const headers = properties.map((prop) => prop.label);
|
const headers = properties.map((prop) => prop.label);
|
||||||
rows.unshift(headers);
|
rows.unshift(headers);
|
||||||
|
|
||||||
// Check the format to export
|
// Check the format to export
|
||||||
if (format.toLowerCase() === "csv") {
|
if (format.toLowerCase() === "csv") {
|
||||||
const csvContent = rows.map((row) => row.join(",")).join("\n");
|
const csvContent = rows.map((row) => row.join(",")).join("\n");
|
||||||
const blob = new Blob([csvContent], {
|
const blob = new Blob([csvContent], {
|
||||||
type: "data:text/csv;charset=utf-8",
|
type: "data:text/csv;charset=utf-8",
|
||||||
});
|
});
|
||||||
const url = URL.createObjectURL(blob);
|
const url = URL.createObjectURL(blob);
|
||||||
const a = document.createElement("a");
|
const a = document.createElement("a");
|
||||||
a.href = url;
|
a.href = url;
|
||||||
a.download =
|
a.download =
|
||||||
$stockTicker.toLowerCase() +
|
$stockTicker.toLowerCase() +
|
||||||
`${filterRule === "annual" ? "_annual" : "_quarter"}_ratios_statement.csv`;
|
`${filterRule === "annual" ? "_annual" : "_quarter"}_balance_sheet_statement.csv`;
|
||||||
document.body.appendChild(a);
|
document.body.appendChild(a);
|
||||||
a.click();
|
a.click();
|
||||||
document.body.removeChild(a);
|
document.body.removeChild(a);
|
||||||
URL.revokeObjectURL(url);
|
URL.revokeObjectURL(url);
|
||||||
} /*else if (format.toLowerCase() === "excel") {
|
} /*else if (format.toLowerCase() === "excel") {
|
||||||
const worksheet = XLSX.utils.aoa_to_sheet(rows);
|
const worksheet = XLSX.utils.aoa_to_sheet(rows);
|
||||||
const workbook = XLSX.utils.book_new();
|
const workbook = XLSX.utils.book_new();
|
||||||
XLSX.utils.book_append_sheet(workbook, worksheet, "Ratios Statement");
|
XLSX.utils.book_append_sheet(workbook, worksheet, "Ratios Statement");
|
||||||
@ -274,6 +276,9 @@
|
|||||||
|
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
|
} else {
|
||||||
|
goto("/pricing");
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
fullStatement = data?.getRatiosStatement;
|
fullStatement = data?.getRatiosStatement;
|
||||||
@ -532,6 +537,17 @@
|
|||||||
class="ml-2 w-full border-gray-600 border bg-[#09090B] sm:hover:bg-[#27272A] ease-out flex flex-row justify-between items-center px-3 py-2 text-white rounded-lg truncate"
|
class="ml-2 w-full border-gray-600 border bg-[#09090B] sm:hover:bg-[#27272A] ease-out flex flex-row justify-between items-center px-3 py-2 text-white rounded-lg truncate"
|
||||||
>
|
>
|
||||||
<span class="truncate text-white">Download</span>
|
<span class="truncate text-white">Download</span>
|
||||||
|
<svg
|
||||||
|
class="{data?.user?.tier === 'Pro'
|
||||||
|
? 'hidden'
|
||||||
|
: ''} ml-1 -mt-0.5 w-3.5 h-3.5"
|
||||||
|
xmlns="http://www.w3.org/2000/svg"
|
||||||
|
viewBox="0 0 24 24"
|
||||||
|
><path
|
||||||
|
fill="#A3A3A3"
|
||||||
|
d="M17 9V7c0-2.8-2.2-5-5-5S7 4.2 7 7v2c-1.7 0-3 1.3-3 3v7c0 1.7 1.3 3 3 3h10c1.7 0 3-1.3 3-3v-7c0-1.7-1.3-3-3-3M9 7c0-1.7 1.3-3 3-3s3 1.3 3 3v2H9z"
|
||||||
|
/></svg
|
||||||
|
>
|
||||||
</Button>
|
</Button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user