浏览代码

feat(*.html): update chart to use apexchart.

Christhoval Barba 1年前
父节点
当前提交
62365ee3d5
共有 2 个文件被更改,包括 354 次插入588 次删除
  1. 339
    580
      gitstats
  2. 15
    8
      html.py

+ 339
- 580
gitstats
文件差异内容过多而无法显示
查看文件


+ 15
- 8
html.py 查看文件

@@ -10,8 +10,12 @@ class HTML(object):
10 10
         self.title = title
11 11
         self.styles = styles
12 12
         self.version = version
13
+        self.content = []
13 14
 
14
-    def create(self, content):
15
+    def add(self, content):
16
+        self.content.append(content)
17
+
18
+    def create(self, content = []):
15 19
         f = open(self.path, 'w')
16 20
         head = self.getHeader(title=self.title)
17 21
         body = self.getBody(content, title=self.title)
@@ -42,6 +46,9 @@ class HTML(object):
42 46
     def getBody(self, content: List[str], title: str) -> str:
43 47
         sidebar = self.getSideBar()
44 48
         topBar = self.getTopBar(title=title)
49
+        if len(self.content) > 0 :
50
+            content = [*self.content, *content]
51
+
45 52
         content = '\n'.join(content)
46 53
         return f'''
47 54
 <body x-data="{{ page: 'main', 'loaded': false, 'darkMode': true, 'stickyMenu': false, 'sidebarToggle': false, 'scrollTop': false }}"
@@ -108,7 +115,7 @@ class HTML(object):
108 115
 	</div>
109 116
 </div>'''
110 117
 
111
-        return f'''
118
+        self.add(f'''
112 119
 <div class="rounded-sm border border-stroke bg-white px-7.5 py-6 shadow-default dark:border-strokedark dark:bg-boxdark">
113 120
 	<div class="flex flex-col">
114 121
 		<div class="flex-1 p-6">
@@ -130,7 +137,7 @@ class HTML(object):
130 137
 			</div>
131 138
 		</div>
132 139
 	</div>
133
-</div>'''
140
+</div>''')
134 141
 
135 142
     def cardItemStat(self, count: str = '$3.456K', title: str = 'Total views', stat: str = None, arrow: str = 'up', icon=None) -> str:
136 143
 
@@ -152,7 +159,7 @@ class HTML(object):
152 159
 	<path d="M11 10.9219C9.38438 10.9219 8.07812 9.61562 8.07812 8C8.07812 6.38438 9.38438 5.07812 11 5.07812C12.6156 5.07812 13.9219 6.38438 13.9219 8C13.9219 9.61562 12.6156 10.9219 11 10.9219ZM11 6.625C10.2437 6.625 9.625 7.24375 9.625 8C9.625 8.75625 10.2437 9.375 11 9.375C11.7563 9.375 12.375 8.75625 12.375 8C12.375 7.24375 11.7563 6.625 11 6.625Z" fill=""></path>
153 160
 </svg>'''
154 161
 
155
-        return f'''
162
+        self.add(f'''
156 163
 <div class="rounded-sm border border-stroke bg-white px-7.5 py-6 shadow-default dark:border-strokedark dark:bg-boxdark">
157 164
 	<div class="flex h-11.5 w-11.5 items-center justify-center rounded-full bg-meta-2 dark:bg-meta-4">
158 165
 		{icon}
@@ -166,7 +173,7 @@ class HTML(object):
166 173
 
167 174
 		{stat_html}
168 175
 	</div>
169
-</div>'''
176
+</div>''')
170 177
 
171 178
     def getSideBar(self) -> str:
172 179
         menu = ''.join([f'''
@@ -411,7 +418,7 @@ class HTML(object):
411 418
     def addChart(self, config: Dict, name: str = None, title: str = 'Chart', className: str=None):
412 419
         if name is None:
413 420
             name = f'chart_{int(time.time())}'
414
-        return self.addCard([f'<div id="{name}" class="-ml-5"></div>'], title=title, className=className, extra=f'''
421
+        self.addCard([f'<div id="{name}" class="-ml-5"></div>'], title=title, className=className, extra=f'''
415 422
 <script>
416 423
     document.addEventListener("DOMContentLoaded", () => {{
417 424
         const chartSelector = document.querySelectorAll("#{name}");
@@ -428,7 +435,7 @@ class HTML(object):
428 435
     
429 436
     def addCard(self, content, title: str = 'Chart', className: str=None, extra: str=None):
430 437
         content = '\n'.join(content)
431
-        return f'''
438
+        self.add(f'''
432 439
 <div
433 440
   class="col-span-12 rounded-sm border border-stroke bg-white px-5 pb-5 pt-7.5 shadow-default dark:border-strokedark dark:bg-boxdark sm:px-7.5 {className or ""}">
434 441
   <div>
@@ -438,4 +445,4 @@ class HTML(object):
438 445
   </div>
439 446
   <div>{content}</div>
440 447
   {extra or ""}
441
-</div>'''
448
+</div>''')