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
0 commit comments