generated from DenysShchypt/Template-Project
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
7676fbb
commit 854dcad
Showing
10 changed files
with
656 additions
and
351 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,45 @@ | ||
export interface IAsset { | ||
asset_id: string; | ||
name: string; | ||
price_usd: number; | ||
volume_1hrs_usd: number; | ||
Data: { | ||
ID: number; | ||
LOGO_URL: string; | ||
NAME: string; | ||
ASSET_DESCRIPTION: string; | ||
PRICE_USD: number; | ||
SEO_TITLE: string; | ||
TOTAL_MKT_CAP_USD: number; | ||
CIRCULATING_MKT_CAP_USD: number; | ||
SEO_DESCRIPTION: string; | ||
PRICE_USD_LAST_UPDATE_TS: number; | ||
}; | ||
} | ||
|
||
export interface IAssetPriceData { | ||
close: number; | ||
high: number; | ||
low: number; | ||
open: number; | ||
time: number; | ||
} | ||
|
||
export interface IAssetPrice { | ||
Aggregated: boolean; | ||
TimeFrom: number; | ||
TimeTo: number; | ||
Data: IAssetPriceData[]; | ||
} | ||
|
||
export interface IAssetsState { | ||
assets: IAsset[]; | ||
favoriteAssets: IAsset[]; | ||
assets: IAssetFavoriteResponses[]; | ||
favoriteAssets: IAssetFavoriteResponses[]; | ||
historyPrice: IAssetPriceResponses[]; | ||
} | ||
|
||
export interface IAssetFavoriteResponses { | ||
name: string; | ||
data: IAsset; | ||
} | ||
|
||
export interface IAssetPriceResponses { | ||
name: string; | ||
data: IAssetPrice; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
import { FC } from 'react'; | ||
import { | ||
Chart as ChartJS, | ||
CategoryScale, | ||
LinearScale, | ||
PointElement, | ||
LineElement, | ||
Title, | ||
Tooltip, | ||
Filler, | ||
Legend, | ||
} from 'chart.js'; | ||
import type { ChartData, ChartOptions, ScriptableContext } from 'chart.js'; | ||
import { Line } from 'react-chartjs-2'; | ||
import { IAssetPriceData } from '../../../common/types/assets'; | ||
|
||
ChartJS.register( | ||
CategoryScale, | ||
LinearScale, | ||
PointElement, | ||
LineElement, | ||
Title, | ||
Tooltip, | ||
Filler, | ||
Legend, | ||
); | ||
interface IAreaChartProps { | ||
data: IAssetPriceData[]; | ||
} | ||
const options: ChartOptions<'line'> = { | ||
responsive: true, | ||
scales: { | ||
x: { | ||
grid: { | ||
display: false, | ||
}, | ||
}, | ||
y: { | ||
display: false, | ||
grid: { | ||
display: false, | ||
}, | ||
}, | ||
}, | ||
plugins: { | ||
legend: { | ||
display: false, | ||
}, | ||
}, | ||
}; | ||
|
||
const AreaChart: FC<IAreaChartProps> = ({ data }) => { | ||
console.log(data); | ||
const values: ChartData<'line'> = { | ||
labels: data.map(el => new Date(el.time).getUTCDate()), | ||
datasets: [ | ||
{ | ||
label: 'Price', | ||
data: data.map(el => el.close), | ||
fill: 'start', | ||
backgroundColor: (context: ScriptableContext<'line'>) => { | ||
const ctx = context.chart.ctx; | ||
const gradient = ctx.createLinearGradient(0, 0, 0, ctx.canvas.height); | ||
gradient.addColorStop(0, '#C1EF00'); | ||
gradient.addColorStop(1, '#232323'); | ||
return gradient; | ||
}, | ||
}, | ||
], | ||
}; | ||
return <Line options={options} data={values} width={300} height={100} />; | ||
}; | ||
|
||
export default AreaChart; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters