๐ ๊ตฌํ๋์ด์ผ ํ ๋ถ๋ถ
์ผ๋จ, h1 ๋ Protocol ๋ช ๋ง ๋ค๋ฅด๊ฒ ํด์ ๋ค์ด๊ฐ ๋ฟ, ์ ๋ก๋ ๋๋ ๊ณผ์ ์ ๊ฐ๋ค.
์ ๋ก๋ ์ดํ ์ฒ๋ฆฌ๊ฐ ๋ฐ๋์ด์ผ ํ๋ค.
group_chart ๋ก ๊ฐ๋ฉด, file_group ๋ณ๋ก h1๊ณผ h2๋ฅผ ๊ตฌ๋ถ์ง์ด์ ๋๊ฐ์ง์ ๊ทธ๋ํ๋ฅผ ๊ทธ๋ ค์ผ ํ๋ค.
๋ฌด์์ด ๋ ๋น๊ต๊ฐ ์๋ ๊น..?
๋ง๋๊ทธ๋ํ๋ก ๊ฒฐ์ .
Fusion Chart ์์ Multi-series Charts ์ด๋ถ๋ถ์ ์ฐพ์๊ณ , ์ด๋ป๊ฒ ์๊ฒจ๋จน์๋์ง ๋ณด์๋ค.
html ์ ์๋์ ๊ฐ๋ค. ( ์ฌ์ดํธ ์ ๊ณต)
<!DOCTYPE html>
<html>
<head>
<title>Django Wrapper | FusionCharts</title>
{% load static %}
<script
type="text/javascript"
src="{% static 'fusioncharts/fusioncharts.js' %}"
></script>
<script
type="text/javascript"
src="{% static 'fusioncharts/themes/fusioncharts.theme.fint.js' %}"
></script>
</head>
<body>
<!-- FusionCharts will render here-->
<div id="chart-1"></div>
<!-- dumping JavaScript code here -->
{{ output|safe }}
</body>
</html>
python ์ฝ๋๋ ์๋์ ๊ฐ๋ค. (์ฌ์ดํธ ์ ๊ณต)
# multi_chart_template
def multi_chart(request):
chartObj = FusionCharts( 'mscolumn2d', 'ex1', '600', '400', 'chart-1', 'json', """{
"chart": {
"caption": "App Publishing Trend",
"subcaption": "2012-2016",
"xaxisname": "Years",
"yaxisname": "Total number of apps in store",
"formatnumberscale": "1",
"plottooltext": "<b>$dataValue</b> apps were available on <b>$seriesName</b> in $label",
"theme": "fusion",
"drawcrossline": "1"
},
"categories": [
{
// nums ๊ฐ ๋ค์ด๊ฐ์ผํจ
"category": [
{
"label": "2012"
},
{
"label": "2013"
},
{
"label": "2014"
},
{
"label": "2015"
},
{
"label": "2016"
}
]
}
],
"dataset": [
{
// h1, h2 = seriesname
"seriesname": "iOS App Store",
"data": [
{
"value": "125000"
},
{
"value": "300000"
},
{
"value": "480000"
},
{
"value": "800000"
},
{
"value": "1100000"
}
]
},
{
"seriesname": "Google Play Store",
"data": [
{
"value": "70000"
},
{
"value": "150000"
},
{
"value": "350000"
},
{
"value": "600000"
},
{
"value": "1400000"
}
]
},
{
"seriesname": "Amazon AppStore",
"data": [
{
"value": "10000"
},
{
"value": "100000"
},
{
"value": "300000"
},
{
"value": "600000"
},
{
"value": "900000"
}
]
}
]
}""")
return render(request, 'multi_chart.html', {'output': chartObj.render()})
์ด๋ป๊ฒ ์๊ฒจ๋จน์๋์ง ํ์ธ ํ์ผ๋ ๋ด ์๋น์ค์ ๋ง๊ฒ ์ ์ฉํด๋ณด์!
(์ด์ ํฌ์คํธ์ ์์ฑํ h1์ ํด๋นํ๋ ์๊ณ ๋ฆฌ์ฆ๋ ์ ์ฉํด์ผ ํ๋ค.)
json ์ธ์ฝ๋ฉ : Python Object (Dictionary, List, Tuple ๋ฑ) ๋ฅผ JSON ๋ฌธ์์ด๋ก ๋ณ๊ฒฝํ๋ ๊ฒ์ JSON Encoding
1. ์ํ๋ ๊ฐ๋ค๋ก json ํ์์ ๋ง๊ฒ ๊ตฌํ๋ ๋์ ๋๋ฆฌ๋ฅผ ๋ง๋ ๋ค.
json.loads(jsonString) ํจ์๋ก String ์ผ๋ก ๊ตฌํ๋์ด์๋ json ์ Python ๋์ ๋๋ฆฌ ํํ๋ก ๋ฐ๊พผ ๊ฒ์ ํ์ธ ํ ํ์
๋ฐ์ดํฐ๋ฅผ ๋ฃ์ด์ฃผ๊ธฐ ์ฉ์ดํ๊ฒ ์ํด์ ๋์ ๋๋ฆฌ ํํ๋ก ๊ด๋ฆฌํ ์ ์๋๋ก ๊ตฌํ!
(http://pythonstudy.xyz/python/article/205-JSON-%EB%8D%B0%EC%9D%B4%ED%83%80)
2. ์ธ์ฝ๋ฉํ์ฌ ํจ์๋ด์ json ์ ๋์ฒดํ๋ค.
Fusion Chart ์ฌ์ฉ ํ๋ฉฐ ์ฐธ๊ณ ํ ์์ ๊ฐ ์ค๋ช
- plottooltext : ํดํ ๊ด๋ จ
์ค์ ์ํํ ์ฝ๋๋ gitHub ์๋ ๋งํฌ ์ฐธ์กฐ
https://github.com/JiYoungDo/Capstone-Design
'Django_Web' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
[Django] ์ ๋ก๋ํ ํ์ผ ๋ด๊ฐ ์ํ๋ ๋๋ก ์ฒ๋ฆฌํ๊ธฐ (0) | 2021.07.19 |
---|---|
[Django][FusionCharts] ์ฌ์ฉ๋ฐฉ๋ฒ & ์ฅ๊ณ ๊ทธ๋ํ ๊ทธ๋ฆฌ๊ธฐ (0) | 2021.06.13 |
[Django] ํ์ผ ์ ๋ก๋ ๊ธ๋ก๋ฒ ์๋น์ค ๊ตฌํํ๊ธฐ (0) | 2021.06.09 |
Django - PythonAnywhere ๊ธ๋ก๋ฒ ์๋น์ค ์์ํ๊ธฐ (0) | 2021.06.02 |
Django Model/ DB (0) | 2021.04.13 |
๋๊ธ