Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weโ€™ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat : chart api #81

Merged
merged 15 commits into from
Nov 23, 2023
46 changes: 46 additions & 0 deletions src/apis/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ const GwangjangAxios = axios.create({
baseURL: "https://api.gwang-jang.co.kr",
});

//๋กœ๊ทธ์ธ ๋ฐ ํšŒ์›๊ฐ€์ž…
export const postLocalLogin = async ({ id, pw }: loginType) => {
const res = await GwangjangAxios.post("/member/auth/signIn", { id, pw });
return res;
Expand Down Expand Up @@ -77,6 +78,51 @@ export const putKakaoRegister = async ({
return res;
};

// ๋ฉ”์ธํŽ˜์ด์ง€
export const getMainBubbleChart = async () => {
const res = await GwangjangAxios.get("/keyword/main");
return res;
};

// ๋””ํ…Œ์ผํŽ˜์ด์ง€
export const getDetailOneLineIntro = async () => {
const res = await GwangjangAxios.get(`/keyword/topic/issueDetail/all`);
return res;
};

export const getDetailLineGraph = async (name: string) => {
const res = await GwangjangAxios.get(`/keyword/trend/${name}`);
return res;
};

export const getDetailSubscribeCount = async (issueId: number) => {
const res = await GwangjangAxios.get(`/member/subscribe/issue/${issueId}`);
return res;
};

export const getDetailBubbleGraph = async (name: string) => {
const res = await GwangjangAxios.get(`/contents/bubbleChart/${name}`);
return res;
};

export const getKeywordArticle = async (keyword: string) => {
const res = await GwangjangAxios.get(`/contents/keyword/${keyword}/NAVER`);
return res;
};
export const getKeywordYoutube = async (keyword: string) => {
const res = await GwangjangAxios.get(`/contents/keyword/${keyword}/YOUTUBE`);
return res;
};
export const getTopicArticle = async (issue: string) => {
const res = await GwangjangAxios.get(`/contents/issueTitle/${issue}/NAVER`);
return res;
};
export const getTopicYoutube = async (issue: string) => {
const res = await GwangjangAxios.get(`/contents/issueTitle/${issue}/YOUTUBE`);
return res;
};

// ์ปค๋ฎค๋‹ˆํ‹ฐ ํŽ˜์ด์ง€
export const getCommunityAllData = async () => {
const res = await GwangjangAxios.get("/community/");
return res;
Expand Down
9 changes: 1 addition & 8 deletions src/components/atoms/button/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -136,20 +136,13 @@ export const LikeBorderButton = ({
);
};

export const QuotBorderButton = ({
onClick,
quotCount,
}: {
onClick?: () => void;
quotCount: number;
}) => {
export const QuotBorderButton = ({ onClick }: { onClick?: () => void }) => {
//์ธ์šฉ ๋ฒ„ํŠผ ํด๋ฆญ ์‹œ ๋ชจ๋‹ฌ์ฐฝ ์˜คํ”ˆ

return (
<>
<BorderStyleButton onClick={onClick}>
<div>์ธ์šฉ</div>
<p>{quotCount}</p>
</BorderStyleButton>
</>
);
Expand Down
6 changes: 4 additions & 2 deletions src/components/atoms/oneLine/style.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,16 @@ export const Container = styled.div`
display: flex;
border-radius: 5px;
background: var(--Gray3_200, #eee);
width: fit-content;
/* width: fit-content; */
height: 20px;
padding: 17px 20px;
padding: 22px 20px;
line-height: 27px;
align-items: center;
.title {
display: flex;
align-items: center;
color: var(--Gray6_500, #959595);
width: 80px;
}
.title::after {
content: "";
Expand All @@ -26,6 +27,7 @@ export const Container = styled.div`

.text {
color: var(--Gray9_800, #424242);
width: 900px;
}

@media (max-width: 650px) {
Expand Down
186 changes: 113 additions & 73 deletions src/components/molecules/bubble/index.tsx
Original file line number Diff line number Diff line change
@@ -1,107 +1,147 @@
import { useEffect } from "react";
/* eslint-disable @typescript-eslint/no-explicit-any */
import { useEffect, useMemo, useState } from "react";

import * as Highcharts from "highcharts";
import HighchartsMore from "highcharts/highcharts-more";
import HighchartsAccessibility from "highcharts/modules/accessibility";
import HighchartsExporting from "highcharts/modules/exporting";
import HighchartsReact from "highcharts-react-official";
import { useParams } from "react-router-dom";
import { useRecoilState } from "recoil";
import { useRecoilState, useSetRecoilState } from "recoil";
import styled from "styled-components";

import { getDetailBubbleGraph } from "@/apis";
import backgroundImg from "@/assets/Bubble/detail-bubbleBackground.svg";
HighchartsExporting(Highcharts);
HighchartsAccessibility(Highcharts);
HighchartsMore(Highcharts);
import "./theme2.css";
//import { bubbleDummydata } from "@/dummy/bubbleData";
import { bubbleDummydata } from "@/dummy/bubbleData";
import { areaState } from "@/recoil/atoms";
import { areaState, detailPageKeyword } from "@/recoil/atoms";
import { BubbleGraphProps } from "@/types";

const Bubble = () => {
const [area, setArea] = useRecoilState<string>(areaState);
const [bubbleGraphData, setBubbleGraphData] = useState<BubbleGraphProps[]>([]);
const setDetailPageKeyword = useSetRecoilState(detailPageKeyword);
const options = useMemo(() => {
return {
chart: {
type: "bubble",
plotBorderWidth: 0,
height: 500,
width: 1080,
marginLeft: 0,
marginRight: 0,
plotBackgroundImage: backgroundImg,
},

const options = {
chart: {
type: "bubble",
plotBorderWidth: 0,
height: 500,
width: 1080,
marginLeft: 0,
marginRight: 0,
plotBackgroundImage: backgroundImg,
},

legend: {
enabled: false,
},
legend: {
enabled: false,
},

tooltip: {
useHTML: true,
headerFormat: "<table>",
pointFormat:
// '<tr><th colspan="2"><h3>{point.name}</h3></th></tr>' +
"<tr><th><h5>ํ‚ค์›Œ๋“œ ๋„์ถœ ํšŸ์ˆ˜ :&nbsp</h5></th><td><h5> {point.z}ํšŒ</h5></td></tr>",
footerFormat: "</table>",
followPointer: true,
style: {
color: "#000",
fontSize: "0.8rem",
tooltip: {
useHTML: true,
headerFormat: "<table>",
pointFormat:
// '<tr><th colspan="2"><h3>{point.name}</h3></th></tr>' +
"<tr><th><h5>ํ‚ค์›Œ๋“œ ๋„์ถœ ํšŸ์ˆ˜ :&nbsp</h5></th><td><h5> {point.z}ํšŒ</h5></td></tr>",
footerFormat: "</table>",
followPointer: true,
style: {
color: "#000",
fontSize: "0.8rem",
},
},
exporting: {
enabled: false,
},
},
exporting: {
enabled: false,
},
plotOptions: {
bubble: {
minSize: 3,
maxSize: 180,
zMin: 0,
zMax: 200,
color: "#212121",
dataLabels: {
enabled: true,
format: "{point.name}",
style: {
color: "#FFF",
textOutline: "none",
fontWeight: "normal",
fontFamily: "Pretendard",
fontSize: 18,
transition: "opacity .1ms",
plotOptions: {
bubble: {
minSize: 3,
maxSize: 180,
zMin: 0,
zMax: 200,
color: "#212121",
dataLabels: {
enabled: true,
format: "{point.name}",
style: {
color: "#FFF",
textOutline: "none",
fontWeight: "normal",
fontFamily: "Pretendard",
fontSize: 18,
transition: "opacity .1ms",
},
},
events: {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
click: function (e: any) {
console.log(e.point.name);
setDetailPageKeyword(e.point.name);
//1๋ถ€ํ„ฐ 9๊นŒ์ง€ ์ˆซ์ž๊ฐ€ ๋“ค์–ด์˜ค๋ฉด ๊ฑฐ๊ธฐ์— ๋งž์ถฐ์„œ ๋ผ์šฐํŒ… ํ•˜๋Š”๊ฒŒ ๋งž์„๋“ฏ
//setWidth(width - 100); // ๋ฐ˜์‘ํ˜• ํ•  ๋•Œ, ์‚ฌ์šฉ ์ž„์‹œ
},
},
},
},
},

series: [
{
data: bubbleDummydata,
colorByPoint: true,
series: [
{
data: bubbleGraphData,
colorByPoint: true,
},
],
credits: {
enabled: false,
},
],
credits: {
enabled: false,
},
};
};
}, [bubbleGraphData, setDetailPageKeyword]);
const { id } = useParams();

useEffect(() => {
if (id === "1" || id === "2" || id === "3") {
const name = decodeURI(decodeURIComponent(id || ""));
if (name === "ํ›„์ฟ ์‹œ๋งˆ ์˜ค์—ผ์ˆ˜" || name === "์ผํšŒ์šฉํ’ˆ ์‚ฌ์šฉ ๊ทœ์ œ ์‹œํ–‰") {
setArea("ํ™˜๊ฒฝ");
} else if (
name === "์ฃผ 69์‹œ๊ฐ„ ๊ทผ๋กœ์‹œ๊ฐ„ ์ œ๋„ ๊ฐœํŽธ" ||
name === "์ฟ ํŒก ๋…ธ๋™์ž ์‚ฌ๋ง" ||
name === "SPC ๋ถˆ๋งค ์šด๋™"
) {
setArea("์ผ์ž๋ฆฌยท๋…ธ๋™");
} else if (id === "4" || id === "5") {
} else if (name === "๊ตญ๋ฏผ์—ฐ๊ธˆ ๊ฐœํ˜" || name === "์ดํƒœ์› ์ฐธ์‚ฌ") {
setArea("์ฃผ๊ฑฐยท์‚ฌํšŒ ์•ˆ์ „๋ง");
} else if (id === "6" || id === "7" || id === "8") {
setArea("ํ™˜๊ฒฝ");
} else if (id === "9" || id === "10") {
} else if (name === "์˜๋Œ€ ์ •์› ํ™•๋Œ€" || name === "์„œ์ด์ดˆ ๊ต์‚ฌ ์‚ฌ๊ฑด") {
setArea("๊ต์œก");
}
}, [area, id, setArea]);

useEffect(() => {
const name = decodeURI(decodeURIComponent(id || ""));
getDetailBubbleGraph(name)
.then((res) => {
const obj = [...res.data.data];
const RealObj = obj.map((item: any) => {
return Object.freeze(item);
});
setBubbleGraphData(RealObj);
})
.catch((err) => {
console.log(err);
setBubbleGraphData(bubbleDummydata);
});
}, [id]);

return (
<Container $area={area}>
<HighchartsReact
highcharts={Highcharts}
options={options}
/>
{bubbleGraphData.length && (
<HighchartsReact
highcharts={Highcharts}
options={options}
/>
)}
</Container>
);
};
Expand All @@ -115,9 +155,9 @@ const Container = styled.div<{ $area: string }>`
filter: ${(props) =>
props.$area === "ํ™˜๊ฒฝ"
? "drop-shadow(0px 6px 30px rgba(26, 226, 118, 0.4)) !important;"
: props.$area === "๊ต์œก"
? "drop-shadow(0px 6px 30px rgba(0, 132, 255, 0.4)) !important;"
: props.$area === "์ผ์ž๋ฆฌยท๋…ธ๋™"
? "drop-shadow(0px 6px 30px rgba(0, 132, 255, 0.4)) !important;"
: props.$area === "๊ต์œก"
? "drop-shadow(0px 6px 30px rgba(255, 153, 0, 0.4)) !important;"
: props.$area === "์ฃผ๊ฑฐยท์‚ฌํšŒ ์•ˆ์ „๋ง"
? "drop-shadow(0px 6px 30px rgba(119, 85, 255, 0.4)) !important;"
Expand All @@ -136,16 +176,16 @@ const Container = styled.div<{ $area: string }>`
fill: ${(props) =>
props.$area === "ํ™˜๊ฒฝ"
? " rgba(26, 226, 118, 0.8) !important;"
: props.$area === "๊ต์œก"
? "rgba(0, 132, 255, 0.8) !important;"
: props.$area === "์ผ์ž๋ฆฌยท๋…ธ๋™"
? "rgba(0, 132, 255, 0.8) !important;"
: props.$area === "๊ต์œก"
? " rgba(255, 153, 0, 0.8) !important;"
: props.$area === "์ฃผ๊ฑฐยท์‚ฌํšŒ ์•ˆ์ „๋ง"
? " rgba(119, 85, 255, 0.8) !important;"
: ""};
}
/* fill: rgba(26, 226, 118, 0.8) !important; */
/* stroke: var(--highcharts-color-2) !important; */
/* stroke: var(โ€”highcharts-color-2) !important; */

/*
filter: drop-shadow(0px 6px 30px rgba(255, 153, 0, 0.30)); ๊ต์œก
Expand Down
6 changes: 3 additions & 3 deletions src/components/molecules/carousel/ArticleCarousel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ import { ArticleDataProps } from "@/types";

import { SlideItem } from "../slideItem";

export const ArticleCarousel = ({ data }: ArticleDataProps) => {
export const ArticleCarousel = ({ data }: { data: ArticleDataProps[] }) => {
const maxSlidesToShow = Math.min(data.length, 4);

console.log(data);
const SliderSetting = {
dots: false,
infinite: true,
Expand Down Expand Up @@ -61,7 +61,7 @@ export const ArticleCarousel = ({ data }: ArticleDataProps) => {
{...SliderSetting}
ref={slickRef}
>
{data.map((item, idx) => (
{data?.map((item, idx) => (
<SlideItemWrapper key={idx}>
<SlideItem data={item} />
</SlideItemWrapper>
Expand Down
Loading