Skip to content

Commit 843a17d

Browse files
committed
test pyecharts
1 parent e40f662 commit 843a17d

File tree

10 files changed

+78
-1
lines changed

10 files changed

+78
-1
lines changed

StockSensation/settings.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,8 @@
3838
'django.contrib.messages',
3939
'django.contrib.staticfiles',
4040
'StockVisualData',
41-
'Stockline'
41+
'Stockline',
42+
'stock_dic_opinion'
4243
]
4344

4445
MIDDLEWARE = [

StockSensation/urls.py

+2
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,15 @@
1818
from django.urls import path
1919
from StockVisualData import views as StockVisualData_views
2020
from Stockline import views as Kline_views
21+
from stock_dic_opinion import views as opinion_views
2122

2223

2324

2425

2526
urlpatterns = [
2627
path('admin/', admin.site.urls),
2728
path('home/',Kline_views.home),
29+
path('pyecharts/',opinion_views.index),
2830
url(r'^$', StockVisualData_views.home, name='home'),
2931
url(r'^index/$', StockVisualData_views.index, name='index'),
3032
url(r'^stockKLine/$', StockVisualData_views.stockKLine, name='stockKline'),

stock_dic_opinion/__init__.py

Whitespace-only changes.

stock_dic_opinion/admin.py

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
from django.contrib import admin
2+
3+
# Register your models here.

stock_dic_opinion/apps.py

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
from django.apps import AppConfig
2+
3+
4+
class StockDicOpinionConfig(AppConfig):
5+
name = 'stock_dic_opinion'

stock_dic_opinion/migrations/__init__.py

Whitespace-only changes.

stock_dic_opinion/models.py

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
from django.db import models
2+
3+
# Create your models here.

stock_dic_opinion/tests.py

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
from django.test import TestCase
2+
3+
# Create your tests here.

stock_dic_opinion/views.py

+43
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
from django.shortcuts import render
2+
3+
# Create your views here.
4+
# from __future__ import unicode_literals
5+
import math
6+
import os
7+
8+
from django.http import HttpResponse
9+
from django.template import loader
10+
from pyecharts import Line3D
11+
12+
13+
REMOTE_HOST = "https://pyecharts.github.io/assets/js"
14+
15+
16+
def index(request):
17+
print(os.path.join(os.getcwd(),'templates/stock_dic_opinion.html'))
18+
template = loader.get_template(os.path.join(os.getcwd(),'templates/stock_dic_opinion.html'))
19+
l3d = line3d()
20+
context = dict(
21+
myechart=l3d.render_embed(),
22+
host=REMOTE_HOST,
23+
script_list=l3d.get_js_dependencies()
24+
)
25+
return HttpResponse(template.render(context, request))
26+
27+
28+
def line3d():
29+
_data = []
30+
for t in range(0, 25000):
31+
_t = t / 1000
32+
x = (1 + 0.25 * math.cos(75 * _t)) * math.cos(_t)
33+
y = (1 + 0.25 * math.cos(75 * _t)) * math.sin(_t)
34+
z = _t + 2.0 * math.sin(75 * _t)
35+
_data.append([x, y, z])
36+
range_color = [
37+
'#313695', '#4575b4', '#74add1', '#abd9e9', '#e0f3f8', '#ffffbf',
38+
'#fee090', '#fdae61', '#f46d43', '#d73027', '#a50026']
39+
line3d = Line3D("3D line plot demo", width=1200, height=600)
40+
line3d.add("", _data, is_visualmap=True,
41+
visual_range_color=range_color, visual_range=[0, 30],
42+
is_grid3D_rotate=True, grid3D_rotate_speed=180)
43+
return line3d

templates/stock_dic_opinion.html

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<!-- myfirstvis/templates/pyecharts.html -->
2+
<!DOCTYPE html>
3+
<html>
4+
5+
<head>
6+
<meta charset="utf-8">
7+
<title>Proudly presented by PycCharts</title>
8+
{% for jsfile_name in script_list %}
9+
<script src="{{ host }}/{{ jsfile_name }}.js"></script>
10+
{% endfor %}
11+
</head>
12+
13+
<body>
14+
{{ myechart|safe }}
15+
</body>
16+
17+
</html>

0 commit comments

Comments
 (0)