From f259ae1e5e701674bb65c957e749cf1e0e5c2540 Mon Sep 17 00:00:00 2001 From: Ste Vaidis Date: Sun, 11 Dec 2022 00:54:27 +0200 Subject: [PATCH] rezise loop issue --- Front/src/coinApi.ts | 8 ++++++- Front/src/coinDetails/coinChart.tsx | 31 +++++++-------------------- Front/src/coinDetails/coinDetails.tsx | 10 +++++---- Front/src/index.css | 7 ++++++ 4 files changed, 28 insertions(+), 28 deletions(-) diff --git a/Front/src/coinApi.ts b/Front/src/coinApi.ts index c811e11..5285a6b 100644 --- a/Front/src/coinApi.ts +++ b/Front/src/coinApi.ts @@ -34,8 +34,14 @@ export interface IGetCoinsChartRequest { per_page: number; } +export interface IChartDataItem { + [index: number]: number, +} + export interface IGetCoinsChartResponse { - [key: string]: any ; + market_caps: Array; + prices: Array; + total_volumes: Array; } export const coinListApi = createApi({ diff --git a/Front/src/coinDetails/coinChart.tsx b/Front/src/coinDetails/coinChart.tsx index 00dac39..6228e56 100644 --- a/Front/src/coinDetails/coinChart.tsx +++ b/Front/src/coinDetails/coinChart.tsx @@ -24,31 +24,11 @@ ChartJS.register( Legend ); -export const options = { - responsive: true, - plugins: { - legend: { - position: 'top' as const, - }, - title: { - display: true, - text: 'Chart.js Line Chart', - }, - }, -}; - export interface ICoinChartProps { coin: string; } -// export interface IChartData { -// [key: string]: any; -// } - - - -// ---------------------------------------- IN export interface IChartDataItem { [index: number]: number, } @@ -59,7 +39,6 @@ export interface IChartData { total_volumes: Array; } -// ---------------------------------------- OUT export interface IChartDataFormattedItem { x: Date; y: number; @@ -70,6 +49,12 @@ export interface IChartDataFormatted extends Array{}; +export const options = { + responsive: false, + maintainAspectRatio: false, + plugins: {}, +}; + const CoinChart = (props: ICoinChartProps): JSX.Element => { console.log("props: ", props); @@ -94,10 +79,10 @@ const CoinChart = (props: ICoinChartProps): JSX.Element => { } return ( -
+
{ data && -
+
{ { dataInfo && isSuccessInfo && <>
-
ID: {dataInfo.id}
+

{dataInfo.id}

Homepage: {dataInfo.links.homepage}
-
Description{dataInfo.description.en}
-
+
+ +
+ Description{dataInfo.description.en} +
} -
) } diff --git a/Front/src/index.css b/Front/src/index.css index 4b932cc..780d045 100644 --- a/Front/src/index.css +++ b/Front/src/index.css @@ -46,3 +46,10 @@ header a { color: #777777; margin-bottom: 20px; } + +.chart-container { + /* width: 100%; */ + height: inherit; + /* height: auto; */ + /* height: 30vh; */ +}