Skip to content

Commit

Permalink
feat: Improvements in stats page (#562)
Browse files Browse the repository at this point in the history
  • Loading branch information
luis-herasme authored Sep 16, 2024
1 parent 79b4f58 commit aa7be76
Show file tree
Hide file tree
Showing 8 changed files with 42 additions and 17 deletions.
3 changes: 3 additions & 0 deletions apps/web/src/components/Charts/Blob/DailyBlobSizeChart.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@ export const DailyBlobSizeChart: FC<Partial<DailyBlobsSizeProps>> = function ({
},
yUnit: "bytes",
}),
grid: {
containLabel: true,
},
series: [
{
name: "Blob Size",
Expand Down
6 changes: 4 additions & 2 deletions apps/web/src/components/Charts/Blob/DailyBlobsChart.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,12 @@ export const DailyBlobsChart: FC<Partial<DailyBlobsChartProps>> = function ({
...buildTimeSeriesOptions({
dates: days,
axisFormatters: {
yAxisTooltip: formatNumber,
yAxisTooltip: (value) => formatNumber(value, "compact"),
},
}),

grid: {
containLabel: true,
},
series: [
{
name: "Total Blobs",
Expand Down
8 changes: 4 additions & 4 deletions apps/web/src/components/Charts/Block/DailyAvgBlobFeeChart.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,12 @@ export const DailyAvgBlobFeeChart: FC<Partial<DailyAvgBlobFeeChartProps>> =
function ({ days, avgBlobFees }) {
const { scaledValues, unit } = useScaledWeiAmounts(avgBlobFees);

const options: EChartOption<EChartOption.SeriesBar> = {
const options: EChartOption<EChartOption.Series> = {
...buildTimeSeriesOptions({
dates: days,
axisFormatters: {
yAxisTooltip: (value) => `${formatNumber(value)} ${unit}`,
yAxisLabel: (value) => `${formatNumber(value)} ${unit}`,
yAxisTooltip: (value) => `${formatNumber(value, "compact")} ${unit}`,
yAxisLabel: (value) => `${formatNumber(value, "compact")} ${unit}`,
},
yUnit: "ethereum",
}),
Expand All @@ -32,7 +32,7 @@ export const DailyAvgBlobFeeChart: FC<Partial<DailyAvgBlobFeeChartProps>> =
{
name: "Avg. Blob Fees",
data: scaledValues,
type: "bar",
type: "line",
},
],
animationEasing: "cubicOut",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,12 @@ export const DailyAvgBlobGasPriceChart: FC<
> = function ({ days, avgBlobGasPrices }) {
const { scaledValues, unit } = useScaledWeiAmounts(avgBlobGasPrices);

const options: EChartOption<EChartOption.SeriesBar> = {
const options: EChartOption<EChartOption.Series> = {
...buildTimeSeriesOptions({
dates: days,
axisFormatters: {
yAxisTooltip: (value) => `${formatNumber(value)} ${unit}`,
yAxisLabel: (value) => `${formatNumber(value)} ${unit}`,
yAxisTooltip: (value) => `${formatNumber(value, "compact")} ${unit}`,
yAxisLabel: (value) => `${formatNumber(value, "compact")} ${unit}`,
},
yUnit: "ethereum",
}),
Expand All @@ -32,7 +32,7 @@ export const DailyAvgBlobGasPriceChart: FC<
{
name: "Avg. Blob Gas Prices",
data: scaledValues,
type: "bar",
type: "line",
},
],
animationEasing: "cubicOut",
Expand Down
4 changes: 2 additions & 2 deletions apps/web/src/components/Charts/Block/DailyBlobFeeChart.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ export const DailyBlobFeeChart: FC<Partial<DailyBlobFeeChartProps>> =
...buildTimeSeriesOptions({
dates: days,
axisFormatters: {
yAxisTooltip: (value) => `${formatNumber(value)} ${unit}`,
yAxisLabel: (value) => `${formatNumber(value)} ${unit}`,
yAxisTooltip: (value) => `${formatNumber(value, "compact")} ${unit}`,
yAxisLabel: (value) => `${formatNumber(value, "compact")} ${unit}`,
},
yUnit: "ethereum",
}),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import type { EChartOption } from "echarts";
import { useTheme } from "next-themes";

import { ChartCard } from "~/components/Cards/ChartCard";
import { useScaledWeiAmounts } from "~/hooks/useScaledWeiAmounts";
import type { DailyBlockStats } from "~/types";
import { buildTimeSeriesOptions, formatNumber } from "~/utils";

Expand All @@ -17,17 +18,25 @@ export type DailyBlobGasComparisonChartProps = Partial<{
export const DailyBlobGasComparisonChart: FC<DailyBlobGasComparisonChartProps> =
function ({ blobAsCalldataGasUsed, blobGasUsed, days, opts = {} }) {
const { resolvedTheme } = useTheme();
const { scaledValues, unit } = useScaledWeiAmounts(
blobGasUsed ? blobGasUsed.map((x) => Number(x)) : []
);

const options: EChartOption<EChartOption.Series> = {
...buildTimeSeriesOptions({
dates: days,
axisFormatters: {
yAxisTooltip: (value) => formatNumber(value, "compact"),
yAxisTooltip: (value) => `${formatNumber(value, "compact")} ${unit}`,
yAxisLabel: (value) => `${formatNumber(value, "compact")} ${unit}`,
},
}),
grid: {
containLabel: true,
},
series: [
{
name: "Blob Gas Used",
data: blobGasUsed,
data: scaledValues,
stack: "gas",
type: "bar",

Expand Down
12 changes: 10 additions & 2 deletions apps/web/src/components/Charts/Block/DailyBlobGasUsedChart.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import type { FC } from "react";
import type { EChartOption } from "echarts";

import { ChartCard } from "~/components/Cards/ChartCard";
import { useScaledWeiAmounts } from "~/hooks/useScaledWeiAmounts";
import type { DailyBlockStats } from "~/types";
import { buildTimeSeriesOptions, formatNumber } from "~/utils";

Expand All @@ -12,17 +13,24 @@ export type DailyBlobGasUsedChartProps = Partial<{

const BaseChart: FC<DailyBlobGasUsedChartProps & { title: string }> =
function ({ days, blobGasUsed, title }) {
const { scaledValues, unit } = useScaledWeiAmounts(
blobGasUsed ? blobGasUsed.map((x) => Number(x)) : []
);
const options: EChartOption<EChartOption.SeriesBar> = {
...buildTimeSeriesOptions({
dates: days,
axisFormatters: {
yAxisTooltip: (value) => formatNumber(value),
yAxisTooltip: (value) => `${formatNumber(value, "compact")} ${unit}`,
yAxisLabel: (value) => `${formatNumber(value, "compact")} ${unit}`,
},
}),
grid: {
containLabel: true,
},
series: [
{
name: "Blob Gas Used",
data: blobGasUsed,
data: scaledValues,
stack: "gas",
type: "bar",
},
Expand Down
5 changes: 4 additions & 1 deletion apps/web/src/components/Charts/Block/DailyBlocksChart.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,12 @@ export const DailyBlocksChart: FC<Partial<DailyBlocksChartProps>> = function ({
...buildTimeSeriesOptions({
dates: days,
axisFormatters: {
yAxisTooltip: (value) => formatNumber(value),
yAxisTooltip: (value) => formatNumber(value, "compact"),
},
}),
grid: {
containLabel: true,
},
series: [
{
name: "Total Blocks",
Expand Down

0 comments on commit aa7be76

Please sign in to comment.