import deephaven.TableTools as tt
import deephaven.Plot as plt


t = tt.emptyTable(50)\
    .update("X = i + 5", "XLow = X -1", "XHigh = X + 1", "Y = Math.random() * 5", "YLow = Y - 1", "YHigh = Y + 1", "USym = i % 2 == 0 ? `AAPL` : `MSFT`")


p = plt.plot("S1", t, "X", "Y").lineColor("black").show()
p2 = plt.plot("S1", t, "X", "Y").plotStyle("bar").gradientVisible(True).show()
p3 = plt.plot("S1", t, "X", "Y").plotStyle("scatter").pointColor("black").pointSize(2).show()
p4 = plt.plot("S1", t, "X", "Y").plotStyle("area").seriesColor("red").show()


p4 = plt.plot3d("S1", t, "X", "X", "Y").show()


pBy = plt.plotBy("S1", t, "X", "Y", "USym").show()
pBy = plt.plot3dBy("S1", t, "X",  "X", "Y", "USym").show()

cp = plt.catPlot("S1", t, "X", "Y").lineColor("black").show()
cp2 = plt.catPlot("S1", t, "X", "Y").plotStyle("bar").gradientVisible(True).show()
cp3 = plt.catPlot("S1", t, "X", "Y").plotStyle("scatter").pointColor("black").pointSize(2).show()
cp4 = plt.catPlot("S1", t, "X", "Y").plotStyle("area").seriesColor("red").show()

cp = plt.catPlot3d("S1", t, "X", "X", "Y").show()

cpBy = plt.catPlotBy("S1", t, "X", "Y", "USym").show()

cpBy = plt.catPlot3dBy("S1", t, "X", "X", "Y", "USym").show()

pp = plt.piePlot("S1", t, "X", "Y")


chp = plt.catHistPlot("S1", t, "X").show()

hp = plt.histPlot("S1", t, "X", 5).show()
hp = plt.histPlot("S1", t, "X", 0, 10, 5).show()

ep = plt.errorBarXY("S1", t, "X", "XLow", "XHigh", "Y", "YLow", "YHigh").show()
epBy = plt.errorBarXYBy("S1", t, "X", "XLow", "XHigh", "Y", "YLow", "YHigh", "USym").show()
ep2 = plt.errorBarX("S1", t, "X", "XLow", "XHigh", "Y").show()
epBy2 = plt.errorBarXBy("S1", t, "X", "XLow", "XHigh", "Y", "USym").show()
ep3 = plt.errorBarY("S1", t, "X", "Y", "YLow", "YHigh").show()
epBy3 = plt.errorBarYBy("S1", t, "X", "Y", "YLow", "YHigh", "USym").show()


doubles = [3, 4, 3, 5, 4, 5]
time = 1491946585000000000
t = tt.newTable(tt.col("USym", ["A", "B", "A", "B", "A", "B"]),
                tt.doubleCol("Open", doubles), tt.doubleCol("High", doubles),
                tt.doubleCol("Low", doubles), tt.doubleCol("Close", doubles))

t = t.updateView("Time = new DBDateTime(time + (MINUTE * i))")

ohlc = plt.ohlcPlot("Test1", t, "Time", "Open", "High", "Low", "Close")

ohlcPlotBy = plt.figure().newChart(0)\
    .chartTitle("Chart Title")\
    .newAxes()\
    .xLabel("X")\
    .yLabel("Y")\
    .ohlcPlotBy("Test1", t, "Time", "Open", "High", "Low", "Close", "USym")


categories = ["Samsung", "Others", "Nokia", "Apple", "MSFT"]
valuesD = [27.8, 55.3, 16.8, 17.1, 23.1]
valuesI = [27, 55, 16, 17, 15]

ap = plt.plot("S1", valuesD, valuesI).show()
ap = plt.plot3d("S1", valuesI, valuesI, valuesI).show()

acp = plt.catPlot("S1", categories, valuesI).show()
acp2 = plt.catPlot3d("S1", categories, categories, valuesD).show()

achp = plt.catHistPlot("S1", categories).show()

app = plt.figure().xLabel("X").yLabel("Y").piePlot("S1", categories, valuesI).pointLabelFormat("{0}").show()

aep = plt.errorBarXY("S1", valuesD, valuesD, valuesD, valuesD, valuesD, valuesD).show()
aep2 = plt.errorBarX("S1", valuesD, valuesD, valuesD, valuesD).show()
aep3 = plt.errorBarY("S1", valuesD, valuesD, valuesD, valuesD).show()


hp = plt.histPlot("S1", valuesD, 5).show()
hp = plt.histPlot("S1", valuesD, 0, 10, 5).show()
hp = plt.histPlot("S1", valuesI, 5).show()

[(32, 'deephaven.Plot.piePlot', 'plt.piePlot', True, 'import deephaven.Plot as plt\n'), (56, 'deephaven.Plot.ohlcPlot', 'plt.ohlcPlot', True, 'import deephaven.Plot as plt\n'), (50, 'deephaven.TableTools.col', 'tt.col', True, 'import deephaven.TableTools as tt\n'), (51, 'deephaven.TableTools.doubleCol', 'tt.doubleCol', True, 'import deephaven.TableTools as tt\n'), (51, 'deephaven.TableTools.doubleCol', 'tt.doubleCol', True, 'import deephaven.TableTools as tt\n'), (52, 'deephaven.TableTools.doubleCol', 'tt.doubleCol', True, 'import deephaven.TableTools as tt\n'), (52, 'deephaven.TableTools.doubleCol', 'tt.doubleCol', True, 'import deephaven.TableTools as tt\n'), (5, 'deephaven.TableTools.emptyTable', 'tt.emptyTable', True, 'import deephaven.TableTools as tt\n'), (15, 'deephaven.Plot.plot3d', 'plt.plot3d', True, 'import deephaven.Plot as plt\n'), (18, 'deephaven.Plot.plotBy', 'plt.plotBy', True, 'import deephaven.Plot as plt\n'), (19, 'deephaven.Plot.plot3dBy', 'plt.plot3dBy', True, 'import deephaven.Plot as plt\n'), (26, 'deephaven.Plot.catPlot3d', 'plt.catPlot3d', True, 'import deephaven.Plot as plt\n'), (28, 'deephaven.Plot.catPlotBy', 'plt.catPlotBy', True, 'import deephaven.Plot as plt\n'), (30, 'deephaven.Plot.catPlot3dBy', 'plt.catPlot3dBy', True, 'import deephaven.Plot as plt\n'), (35, 'deephaven.Plot.catHistPlot', 'plt.catHistPlot', True, 'import deephaven.Plot as plt\n'), (37, 'deephaven.Plot.histPlot', 'plt.histPlot', True, 'import deephaven.Plot as plt\n'), (38, 'deephaven.Plot.histPlot', 'plt.histPlot', True, 'import deephaven.Plot as plt\n'), (40, 'deephaven.Plot.errorBarXY', 'plt.errorBarXY', True, 'import deephaven.Plot as plt\n'), (41, 'deephaven.Plot.errorBarXYBy', 'plt.errorBarXYBy', True, 'import deephaven.Plot as plt\n'), (42, 'deephaven.Plot.errorBarX', 'plt.errorBarX', True, 'import deephaven.Plot as plt\n'), (43, 'deephaven.Plot.errorBarXBy', 'plt.errorBarXBy', True, 'import deephaven.Plot as plt\n'), (44, 'deephaven.Plot.errorBarY', 'plt.errorBarY', True, 'import deephaven.Plot as plt\n'), (45, 'deephaven.Plot.errorBarYBy', 'plt.errorBarYBy', True, 'import deephaven.Plot as plt\n'), (70, 'deephaven.Plot.plot', 'plt.plot', True, 'import deephaven.Plot as plt\n'), (71, 'deephaven.Plot.plot3d', 'plt.plot3d', True, 'import deephaven.Plot as plt\n'), (73, 'deephaven.Plot.catPlot', 'plt.catPlot', True, 'import deephaven.Plot as plt\n'), (74, 'deephaven.Plot.catPlot3d', 'plt.catPlot3d', True, 'import deephaven.Plot as plt\n'), (76, 'deephaven.Plot.catHistPlot', 'plt.catHistPlot', True, 'import deephaven.Plot as plt\n'), (80, 'deephaven.Plot.errorBarXY', 'plt.errorBarXY', True, 'import deephaven.Plot as plt\n'), (81, 'deephaven.Plot.errorBarX', 'plt.errorBarX', True, 'import deephaven.Plot as plt\n'), (82, 'deephaven.Plot.errorBarY', 'plt.errorBarY', True, 'import deephaven.Plot as plt\n'), (85, 'deephaven.Plot.histPlot', 'plt.histPlot', True, 'import deephaven.Plot as plt\n'), (86, 'deephaven.Plot.histPlot', 'plt.histPlot', True, 'import deephaven.Plot as plt\n'), (87, 'deephaven.Plot.histPlot', 'plt.histPlot', True, 'import deephaven.Plot as plt\n'), (9, 'deephaven.Plot.plot', 'plt.plot', True, 'import deephaven.Plot as plt\n'), (21, 'deephaven.Plot.catPlot', 'plt.catPlot', True, 'import deephaven.Plot as plt\n'), (10, 'deephaven.Plot.plot', 'plt.plot', True, 'import deephaven.Plot as plt\n'), (12, 'deephaven.Plot.plot', 'plt.plot', True, 'import deephaven.Plot as plt\n'), (22, 'deephaven.Plot.catPlot', 'plt.catPlot', True, 'import deephaven.Plot as plt\n'), (24, 'deephaven.Plot.catPlot', 'plt.catPlot', True, 'import deephaven.Plot as plt\n'), (11, 'deephaven.Plot.plot', 'plt.plot', True, 'import deephaven.Plot as plt\n'), (23, 'deephaven.Plot.catPlot', 'plt.catPlot', True, 'import deephaven.Plot as plt\n'), (78, 'deephaven.Plot.figure', 'plt.figure', True, 'import deephaven.Plot as plt\n'), (58, 'deephaven.Plot.figure', 'plt.figure', True, 'import deephaven.Plot as plt\n')]