Skip to content
Snippets Groups Projects
Commit aed9141d authored by Aggarwal Himanshu's avatar Aggarwal Himanshu
Browse files

Add and configure crypto line chart

parent f4e93160
No related branches found
No related tags found
3 merge requests!7Merge develop to main,!6Add a Table View for Cryptocurrencies,!4Improve Table UI and make it more modular
import React, { useRef } from "react";
import ReactECharts from "echarts-for-react";
import { cryptoLineChartOptions } from "../../constants";
import { useCryptoTimeSeriesData } from "../../queries";
function CryptoRowLineChart({ currencyId, color }) {
const cryptoQuery = useCryptoTimeSeriesData(currencyId, 1, "hourly");
const chartRef = useRef(null);
return (
<ReactECharts
ref={chartRef}
option={cryptoLineChartOptions(cryptoQuery.data?.prices, color)}
style={{
height: "100%",
}}
/>
);
}
export default CryptoRowLineChart;
......@@ -65,6 +65,77 @@ export const cryptoChartOptions = (colors = [], dark = false) => {
};
};
export const cryptoLineChartOptions = (seriesData = [], color = "#3590F3") => {
return {
grid: {
bottom: 10,
right: 10,
top: 10,
left: 10,
},
xAxis: {
show: false,
type: "time",
silent: false,
splitLine: {
show: false,
},
splitArea: {
show: false,
},
},
yAxis: {
show: false,
type: "value",
splitArea: {
show: false,
},
splitLine: {
show: false,
},
min: "dataMin",
max: "dataMax",
},
series: [
{
type: "line",
data: seriesData,
name: "Solana",
smooth: true,
symbol: "none",
lineStyle: {
width: 3,
shadowOffsetY: -1,
color: color,
shadowColor: color,
shadowOffsetX: 0,
shadowBlur: 5,
cap: "round",
opacity: 1,
},
animation: false,
},
{
type: "scatter",
data: seriesData.slice(-1),
name: "ABC",
smooth: true,
symbol: "circle",
symbolSize: 20,
itemStyle: {
shadowOffsetY: 0,
color: color,
shadowColor: color,
shadowOffsetX: 0,
shadowBlur: 15,
opacity: 0.1,
},
animation: false,
},
],
};
};
export const cryptocurrencies = [
{
id: "bitcoin",
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment