Skip to content

Commit

Permalink
feat/qb-2037: Update chart scale
Browse files Browse the repository at this point in the history
  • Loading branch information
BoThe1K committed Nov 1, 2023
1 parent 01d47ce commit c561259
Show file tree
Hide file tree
Showing 7 changed files with 48 additions and 11 deletions.
10 changes: 10 additions & 0 deletions .pnp.cjs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions apps/web-stratos/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
"big.js": "^6.2.1",
"color": "^4.2.3",
"copy-to-clipboard": "^3.3.3",
"d3-scale": "^4.0.2",
"dayjs": "^1.11.7",
"ethers": "5.7.2",
"framer-motion": "^10.12.8",
Expand Down Expand Up @@ -94,6 +95,7 @@
"@testing-library/react": "^14.0.0",
"@types/big.js": "^6.1.6",
"@types/color": "^3.0.3",
"@types/d3-scale": "^4",
"@types/eslint": "^8.37.0",
"@types/esprima": "^4.0.3",
"@types/jest": "^29.5.1",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,19 +1,30 @@
import { useId, FC } from 'react';

import { BigNumber } from 'ethers';

import { Tooltip, BarChart, CartesianGrid, XAxis, YAxis, Bar } from 'recharts';

interface ITokenomicChart {
total: string;
data?: any[];
}

const TokenomicChart: FC<ITokenomicChart> = ({ data }) => {
const TokenomicChart: FC<ITokenomicChart> = ({ data, total }) => {
const chartId = useId();

return (
<BarChart width={600} height={250} data={data} id={chartId}>
<BarChart
width={600}
height={250}
data={data}
id={chartId}
{...{
overflow: 'visible',
}}
>
<CartesianGrid stroke="#ccc" />
<XAxis dataKey="legendKey" />
<YAxis tickCount={10_000} domain={[0, 'dataMax']} tick={{ fontSize: 12 }} />
<YAxis scale="log" tick={{ fontSize: 12 }} domain={[1_00, total]} />
<Tooltip />
<Bar dataKey="value" isAnimationActive={false} />
</BarChart>
Expand Down
12 changes: 6 additions & 6 deletions apps/web-stratos/src/screens/home/components/hero/index.tsx
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
import Box from '@/components/box';
import Loading from '@/components/loading';
import OnlineVotingPower from '@/screens/home/components/hero/components/online_voting_power';
import TokenPrice from '@/screens/home/components/hero/components/token_price';
// import TokenPrice from '@/screens/home/components/hero/components/token_price';
import { useHero } from '@/screens/home/components/hero/hooks';
import { FC } from 'react';

const Hero: FC<ComponentDefault> = (props) => {
const { state } = useHero();
let component = null;
if (!state.loading) {
if (state.tokenPriceHistory.length) {
component = <TokenPrice items={state.tokenPriceHistory} />;
} else {
component = <OnlineVotingPower />;
}
// if (state.tokenPriceHistory.length) {
// component = <TokenPrice items={state.tokenPriceHistory} />;
// } else {
component = <OnlineVotingPower />;
// }
} else {
component = <Loading />;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,10 @@ const Tokenomics: FC<ComponentDefault> = ({ className }) => {
))}
</div>
<div className={classes.content}>
<TokenomicChart data={data} />
<TokenomicChart
data={data.filter((x) => x.value !== 0)}
total={prettyFormat(tokenomics.total, 18, 0)}
/>
</div>
</Box>
);
Expand Down
2 changes: 1 addition & 1 deletion packages/ui/public/locales/en/common.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
"price": "Price",
"inflation": "Inflation",
"apr": "APR",
"miningReward": "Mining Reward",
"miningReward": "Chain Reward",
"success": "Success",
"fail": "Fail",
"filterBy": "Filter By...",
Expand Down
11 changes: 11 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -5044,6 +5044,15 @@ __metadata:
languageName: node
linkType: hard

"@types/d3-scale@npm:^4":
version: 4.0.6
resolution: "@types/d3-scale@npm:4.0.6"
dependencies:
"@types/d3-time": "*"
checksum: 1c76c74b0333e8a1e0a2e45d26a22a448808b5381f72359b4442d02d7c77dae976c03559569e8347635adfa77fe781a70717e331b819064aeea7b9e24028c1aa
languageName: node
linkType: hard

"@types/d3-scale@npm:^4.0.2":
version: 4.0.3
resolution: "@types/d3-scale@npm:4.0.3"
Expand Down Expand Up @@ -15972,6 +15981,7 @@ __metadata:
"@testing-library/react": ^14.0.0
"@types/big.js": ^6.1.6
"@types/color": ^3.0.3
"@types/d3-scale": ^4
"@types/eslint": ^8.37.0
"@types/esprima": ^4.0.3
"@types/jest": ^29.5.1
Expand All @@ -15998,6 +16008,7 @@ __metadata:
color: ^4.2.3
copy-to-clipboard: ^3.3.3
csstype: ^3.1.2
d3-scale: ^4.0.2
dayjs: ^1.11.7
dotenv: ^16.0.3
eslint: ^8.40.0
Expand Down

0 comments on commit c561259

Please sign in to comment.