Commit e23d82fa authored by Aurélien Campéas's avatar Aurélien Campéas
Browse files

remove useless modules and test

parent 09cb2bcc22e9
<div id="mydiv" class="plotly-graph-div"></div><script type="text/javascript"> window.PLOTLYENV=window.PLOTLYENV || {}; Plotly.newPlot("mydiv", [{"name": "banana_volume_consumption", "type": "scatter", "x": ["2017-01-01", "2017-01-02", "2017-01-03", "2017-01-04", "2017-01-05"], "y": [1.0, 2.0, 3.0, 4.0, 5.0]}], {"showlegend": true}, {displaylogo: false, modeBarButtonsToRemove: ["sendDataToCloud"]})</script>
\ No newline at end of file
from pathlib import Path
import pandas as pd
from tshistory.tsio import timeseries
from tsview.plot import plot
from tsview.util import argsdict
DATADIR = Path(__file__).parent / 'data'
def test_plot(engine, refresh):
serie = pd.Series([1, 2, 3, 4, 5],
index=pd.date_range(start='2017-1-1',
freq='D',
periods=5))
tsh = timeseries()
with engine.begin() as cn:
tsh.insert(cn, serie, 'banana_volume_consumption', 'Babar')
args = argsdict({'series': ['banana_volume_consumption']})
plotted = plot(args, engine, timeseries, divid='mydiv').strip().encode('utf-8')
refpath = DATADIR / 'plotted.html'
if refresh:
refpath.write_bytes(plotted)
assert refpath.read_bytes() == plotted
......@@ -6,7 +6,6 @@ from dash import _utils
from tshistory.tsio import timeseries
from tsview.util import argsdict as _argsdict
from tsview.plot import plot
# monkeypatch dash utility
......
import plotly.graph_objs as go
from tsview.util import plot_to_htmldiv
def plot(args, engine, tshclass, divid=None):
tsh = tshclass()
series = []
with engine.begin() as cn:
for name in args.series:
series.append((name, tsh.get(cn, name)))
traces = []
for name, ts in series:
traces.append(
go.ScatterGL(
name=name,
x=ts.index,
y=ts.values)
)
layout = go.Layout(
showlegend=True,
)
return plot_to_htmldiv(traces, layout, divid)
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment