Skip to content

Add code for more csv downloads #1689

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 29 additions & 0 deletions src/components/ECharts/ChainChart/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -554,6 +554,35 @@ export default function AreaChart({
denomination,
isThemeDark
])

let unique = []
const days = {}
series.forEach(({ name, data }) => {
if (data == null || data.length === 0) {
return
}
unique.push(name)
data.forEach((day) => {
const ts = new Date(day[0]).toDateString()
if (days[ts] === undefined) {
days[ts] = {}
}
days[ts][name] = day[1]
})
})
const rows = Object.entries(days)
.sort((a, b) => new Date(a[0]).getTime() - new Date(b[0]).getTime())
.map(([timestamp, dayInfo]) =>
[new Date(timestamp).getTime() / 1e3, timestamp].concat(unique.map((name) => dayInfo[name] ?? ''))
)
console.log(
[['UNIX Timestamp', 'Date', ...unique]]
.concat(rows)
.map((r) => r.join(','))
.join('\n')
)


const createInstance = useCallback(() => {
const instance = echarts.getInstanceByDom(document.getElementById(id))

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -392,7 +392,7 @@ export function useFetchAndFormatChartData({
if (fdv === 'true' && fdvData) {
chartsUnique.push('FDV')

const totalSupply = fdvData['data']['total_supply']
const totalSupply = fdvData?.['data']?.['total_supply']

protocolCGData['prices'].forEach(([dateMs, price]) => {
const date = Math.floor(nearestUtc(dateMs) / 1000)
Expand Down Expand Up @@ -1037,6 +1037,18 @@ export function useFetchAndFormatChartData({
fetchingDevMetrics ||
fetchingAggregatorsVolume

console.log(
[['UNIX Timestamp', 'Date', ...chartsUnique]]
.concat(
finalData.map((row) => [
row.date,
new Date(Number(row.date) * 1e3).toDateString(),
...chartsUnique.map((key) => row[key] ?? '')
])
)
.map((row) => row.join(','))
.join('\n')
)
return {
fetchingTypes,
isLoading,
Expand Down