Source code for webviz_line_chart

from webviz_plotly import FilteredPlotly
import warnings


[docs]class LineChart(FilteredPlotly): """Line chart page element. :param data: Either a file path to a `csv` file or a :class:`pandas.DataFrame`. If a dataframe is given, each column is one line in the chart. The dataframe index is used for the horizontal values. Similarly for the `csv` file, where a special column named ``index`` will be used for the horizontal values. """ def __init__(self, data, logy=False, *args, **kwargs): self.logy = logy super(LineChart, self).__init__( data, *args, logy=logy, **kwargs)
[docs] def process_data(self, data): lines = [] for column in data.columns: if self.logy and column not in ['index', 'category', 'dateslider']\ and any(float(x) <= 0 for x in data[column].tolist()): warnings.warn('Non-positive values are not supported in a' ' logarithmic scale.') lines.append({ 'y': data[column].tolist(), 'x': data.index.tolist(), 'type': 'scatter', 'name': column }) return lines