forked from streamlit/streamlit-example
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcharts_additions.py
39 lines (30 loc) · 1.11 KB
/
charts_additions.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
from altair.vegalite.v4.schema.core import Legend
from chart_base import ChartBase
import pandas as pd
from urval import UrvalsLista
from grunddata import Grunddata
import altair as alt
class Chart4PercentLineRule(ChartBase):
def __init__(self):
super().__init__(pd.DataFrame(data={"y": [Grunddata.riksdagsspärr]}), title='', subtitle='', urval=None)
def add_transform_fold(self):
pass
def add_marker(self):
self.c = self.c.mark_rule(color="black", strokeWidth=1)
def add_encode(self):
self.c = self.c.encode(
y="y"
)
class ChartElectionDayRule(ChartBase):
def __init__(self):
# create a date object for the election day
election_day = pd.to_datetime(Grunddata.valdag)
super().__init__(pd.DataFrame(data={"x": [election_day]}), title='', subtitle='', urval=None)
def add_transform_fold(self):
pass
def add_marker(self):
self.c = self.c.mark_rule(color="grey", strokeWidth=1.8, strokeDash=[2, 2])
def add_encode(self):
self.c = self.c.encode(
x="x"
)