# Path: lantern/plotting/plotobj.py
# class BasePlot(with_metaclass(ABCMeta)):
#     def __init__(self, backend):
#         pass
# 
#     @abstractmethod
#     def show(self, title='', xlabel='', ylabel='', xaxis=True, yaxis=True, xticks=True, yticks=True, legend=True, grid=True, **kwargs):
#         pass
# 
#     @abstractmethod
#     def area(self, data, color=None, y_axis='left', stacked=False, **kwargs):
#         pass
# 
#     @abstractmethod
#     def bar(self, data, color=None, y_axis='left', stacked=False, **kwargs):
#         pass
# 
#     @abstractmethod
#     def hist(self, data, color=None, y_axis='left', stacked=False, **kwargs):
#         pass
# 
#     @abstractmethod
#     def hline(self, y, color=None, **kwargs):
#         pass
# 
#     @abstractmethod
#     def hspan(self, yhigh, ylow, color=None, **kwargs):
#         pass
# 
#     @abstractmethod
#     def line(self, data, color=None, y_axis='left', **kwargs):
#         pass
# 
#     @abstractmethod
#     def scatter(self, data, color=None, x=None, y=None, y_axis='left', **kwargs):
#         pass
# 
#     @abstractmethod
#     def step(self, data, color=None, y_axis='left', **kwargs):
#         pass
# 
#     @abstractmethod
#     def vline(self, x, color=None, **kwargs):
#         pass
# 
#     @abstractmethod
#     def vspan(self, xhigh, xlow, color=None, **kwargs):
#         pass
# 
# Path: lantern/plotting/plotutils.py
# def get_color(i, col, color):
#     if isinstance(color, list):
#         c = (color[i:i + 1] or [_r()])[0]
#     elif isinstance(color, dict):
#         c = color.get(col, _r())
#     elif isinstance(color, str) and color:
#         c = color
#     else:
#         c = _r()
#     return c


from IPython.display import display
from ipywidgets import VBox
from bqplot.axes import Axis
from bqplot.scales import LinearScale
from bqplot.marks import Lines
from bqplot.figure import Figure
from bqplot.interacts import BrushIntervalSelector
from bqplot.toolbar import Toolbar
from .plotobj import BasePlot
from .plotutils import get_color
# import bqplot.pyplot as plt


class BQPlotPlot(BasePlot):
    def __init__(self, size=None, theme=None):
        self.size = size or (12, 5)
        self._x_sc = LinearScale()
        self._y_sc = LinearScale()

        self._axes = []
        self._marks = []

    def _newAx(self, y_side='left', color='black'):
        # axis managemens
        raise NotImplementedError()

    def show(self, title='', xlabel='', ylabel='', xaxis=True, yaxis=True, xticks=True, yticks=True, legend=True, grid=True, **kwargs):
        # require all data to be present before plotting
        x = Axis(title=xlabel, scale=self._x_sc)
        y = Axis(title=ylabel, scale=self._y_sc, orientation='vertical')
        fig = Figure(axes=[x, y], marks=self._marks, title=title, legend_location='right', interactions=BrushIntervalSelector())

        display(VBox([fig, Toolbar(figure=fig)]))

    def area(self, data, color=None, y_axis='left', stacked=False, **kwargs):
        raise NotImplementedError()

    def bar(self, data, color=None, y_axis='left', stacked=False, **kwargs):

# Path: lantern/plotting/plotobj.py
# class BasePlot(with_metaclass(ABCMeta)):
#     def __init__(self, backend):
#         pass
# 
#     @abstractmethod
#     def show(self, title='', xlabel='', ylabel='', xaxis=True, yaxis=True, xticks=True, yticks=True, legend=True, grid=True, **kwargs):
#         pass
# 
#     @abstractmethod
#     def area(self, data, color=None, y_axis='left', stacked=False, **kwargs):
#         pass
# 
#     @abstractmethod
#     def bar(self, data, color=None, y_axis='left', stacked=False, **kwargs):
#         pass
# 
#     @abstractmethod
#     def hist(self, data, color=None, y_axis='left', stacked=False, **kwargs):
#         pass
# 
#     @abstractmethod
#     def hline(self, y, color=None, **kwargs):
#         pass
# 
#     @abstractmethod
#     def hspan(self, yhigh, ylow, color=None, **kwargs):
#         pass
# 
#     @abstractmethod
#     def line(self, data, color=None, y_axis='left', **kwargs):
#         pass
# 
#     @abstractmethod
#     def scatter(self, data, color=None, x=None, y=None, y_axis='left', **kwargs):
#         pass
# 
#     @abstractmethod
#     def step(self, data, color=None, y_axis='left', **kwargs):
#         pass
# 
#     @abstractmethod
#     def vline(self, x, color=None, **kwargs):
#         pass
# 
#     @abstractmethod
#     def vspan(self, xhigh, xlow, color=None, **kwargs):
#         pass
# 
# Path: lantern/plotting/plotutils.py
# def get_color(i, col, color):
#     if isinstance(color, list):
#         c = (color[i:i + 1] or [_r()])[0]
#     elif isinstance(color, dict):
#         c = color.get(col, _r())
#     elif isinstance(color, str) and color:
#         c = color
#     else:
#         c = _r()
#     return c


# Path: lantern/plotting/plot_bqplot.py
from IPython.display import display
from ipywidgets import VBox
from bqplot.axes import Axis
from bqplot.scales import LinearScale
from bqplot.marks import Lines
from bqplot.figure import Figure
from bqplot.interacts import BrushIntervalSelector
from bqplot.toolbar import Toolbar
from .plotobj import BasePlot
from .plotutils import get_color

# import bqplot.pyplot as plt


class BQPlotPlot(BasePlot):
    def __init__(self, size=None, theme=None):
        self.size = size or (12, 5)
        self._x_sc = LinearScale()
        self._y_sc = LinearScale()

        self._axes = []
        self._marks = []

    def _newAx(self, y_side='left', color='black'):
        # axis managemens
        raise NotImplementedError()

    def show(self, title='', xlabel='', ylabel='', xaxis=True, yaxis=True, xticks=True, yticks=True, legend=True, grid=True, **kwargs):
        # require all data to be present before plotting
        x = Axis(title=xlabel, scale=self._x_sc)
        y = Axis(title=ylabel, scale=self._y_sc, orientation='vertical')
        fig = Figure(axes=[x, y], marks=self._marks, title=title, legend_location='right', interactions=BrushIntervalSelector())

        display(VBox([fig, Toolbar(figure=fig)]))

    def area(self, data, color=None, y_axis='left', stacked=False, **kwargs):
        raise NotImplementedError()

    def bar(self, data, color=None, y_axis='left', stacked=False, **kwargs):

        raise NotImplementedError()