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, 5, 32, 35), 'deephaven.Plot.piePlot', 'plt.piePlot', ({(32, 17, 32, 21): '"""S1"""', (32, 23, 32, 24): 't', (32, 26, 32, 29): '"""X"""', (32, 31, 32, 34): '"""Y"""'}, {}), "('S1', t, 'X', 'Y')", True, 'import deephaven.Plot as plt\n'), ((56, 7, 56, 71), 'deephaven.Plot.ohlcPlot', 'plt.ohlcPlot', ({(56, 20, 56, 27): '"""Test1"""', (56, 29, 56, 30): 't', (56, 32, 56, 38): '"""Time"""', (56, 40, 56, 46): '"""Open"""', (56, 48, 56, 54): '"""High"""', (56, 56, 56, 61): '"""Low"""', (56, 63, 56, 70): '"""Close"""'}, {}), "('Test1', t, 'Time', 'Open', 'High', 'Low', 'Close')", True, 'import deephaven.Plot as plt\n'), ((50, 16, 50, 62), 'deephaven.TableTools.col', 'tt.col', ({(50, 23, 50, 29): '"""USym"""', (50, 31, 50, 61): "['A', 'B', 'A', 'B', 'A', 'B']"}, {}), "('USym', ['A', 'B', 'A', 'B', 'A', 'B'])", True, 'import deephaven.TableTools as tt\n'), ((51, 16, 51, 45), 'deephaven.TableTools.doubleCol', 'tt.doubleCol', ({(51, 29, 51, 35): '"""Open"""', (51, 37, 51, 44): 'doubles'}, {}), "('Open', doubles)", True, 'import deephaven.TableTools as tt\n'), ((51, 47, 51, 76), 'deephaven.TableTools.doubleCol', 'tt.doubleCol', ({(51, 60, 51, 66): '"""High"""', (51, 68, 51, 75): 'doubles'}, {}), "('High', doubles)", True, 'import deephaven.TableTools as tt\n'), ((52, 16, 52, 44), 'deephaven.TableTools.doubleCol', 'tt.doubleCol', ({(52, 29, 52, 34): '"""Low"""', (52, 36, 52, 43): 'doubles'}, {}), "('Low', doubles)", True, 'import deephaven.TableTools as tt\n'), ((52, 46, 52, 76), 'deephaven.TableTools.doubleCol', 'tt.doubleCol', ({(52, 59, 52, 66): '"""Close"""', (52, 68, 52, 75): 'doubles'}, {}), "('Close', doubles)", True, 'import deephaven.TableTools as tt\n'), ((5, 4, 5, 21), 'deephaven.TableTools.emptyTable', 'tt.emptyTable', ({(5, 18, 5, 20): '50'}, {}), '(50)', True, 'import deephaven.TableTools as tt\n'), ((15, 5, 15, 39), 'deephaven.Plot.plot3d', 'plt.plot3d', ({(15, 16, 15, 20): '"""S1"""', (15, 22, 15, 23): 't', (15, 25, 15, 28): '"""X"""', (15, 30, 15, 33): '"""X"""', (15, 35, 15, 38): '"""Y"""'}, {}), "('S1', t, 'X', 'X', 'Y')", True, 'import deephaven.Plot as plt\n'), ((18, 6, 18, 43), 'deephaven.Plot.plotBy', 'plt.plotBy', ({(18, 17, 18, 21): '"""S1"""', (18, 23, 18, 24): 't', (18, 26, 18, 29): '"""X"""', (18, 31, 18, 34): '"""Y"""', (18, 36, 18, 42): '"""USym"""'}, {}), "('S1', t, 'X', 'Y', 'USym')", True, 'import deephaven.Plot as plt\n'), ((19, 6, 19, 51), 'deephaven.Plot.plot3dBy', 'plt.plot3dBy', ({(19, 19, 19, 23): '"""S1"""', (19, 25, 19, 26): 't', (19, 28, 19, 31): '"""X"""', (19, 34, 19, 37): '"""X"""', (19, 39, 19, 42): '"""Y"""', (19, 44, 19, 50): '"""USym"""'}, {}), "('S1', t, 'X', 'X', 'Y', 'USym')", True, 'import deephaven.Plot as plt\n'), ((26, 5, 26, 42), 'deephaven.Plot.catPlot3d', 'plt.catPlot3d', ({(26, 19, 26, 23): '"""S1"""', (26, 25, 26, 26): 't', (26, 28, 26, 31): '"""X"""', (26, 33, 26, 36): '"""X"""', (26, 38, 26, 41): '"""Y"""'}, {}), "('S1', t, 'X', 'X', 'Y')", True, 'import deephaven.Plot as plt\n'), ((28, 7, 28, 47), 'deephaven.Plot.catPlotBy', 'plt.catPlotBy', ({(28, 21, 28, 25): '"""S1"""', (28, 27, 28, 28): 't', (28, 30, 28, 33): '"""X"""', (28, 35, 28, 38): '"""Y"""', (28, 40, 28, 46): '"""USym"""'}, {}), "('S1', t, 'X', 'Y', 'USym')", True, 'import deephaven.Plot as plt\n'), ((30, 7, 30, 54), 'deephaven.Plot.catPlot3dBy', 'plt.catPlot3dBy', ({(30, 23, 30, 27): '"""S1"""', (30, 29, 30, 30): 't', (30, 32, 30, 35): '"""X"""', (30, 37, 30, 40): '"""X"""', (30, 42, 30, 45): '"""Y"""', (30, 47, 30, 53): '"""USym"""'}, {}), "('S1', t, 'X', 'X', 'Y', 'USym')", True, 'import deephaven.Plot as plt\n'), ((35, 6, 35, 35), 'deephaven.Plot.catHistPlot', 'plt.catHistPlot', ({(35, 22, 35, 26): '"""S1"""', (35, 28, 35, 29): 't', (35, 31, 35, 34): '"""X"""'}, {}), "('S1', t, 'X')", True, 'import deephaven.Plot as plt\n'), ((37, 5, 37, 34), 'deephaven.Plot.histPlot', 'plt.histPlot', ({(37, 18, 37, 22): '"""S1"""', (37, 24, 37, 25): 't', (37, 27, 37, 30): '"""X"""', (37, 32, 37, 33): '5'}, {}), "('S1', t, 'X', 5)", True, 'import deephaven.Plot as plt\n'), ((38, 5, 38, 41), 'deephaven.Plot.histPlot', 'plt.histPlot', ({(38, 18, 38, 22): '"""S1"""', (38, 24, 38, 25): 't', (38, 27, 38, 30): '"""X"""', (38, 32, 38, 33): '0', (38, 35, 38, 37): '10', (38, 39, 38, 40): '5'}, {}), "('S1', t, 'X', 0, 10, 5)", True, 'import deephaven.Plot as plt\n'), ((40, 5, 40, 72), 'deephaven.Plot.errorBarXY', 'plt.errorBarXY', ({(40, 20, 40, 24): '"""S1"""', (40, 26, 40, 27): 't', (40, 29, 40, 32): '"""X"""', (40, 34, 40, 40): '"""XLow"""', (40, 42, 40, 49): '"""XHigh"""', (40, 51, 40, 54): '"""Y"""', (40, 56, 40, 62): '"""YLow"""', (40, 64, 40, 71): '"""YHigh"""'}, {}), "('S1', t, 'X', 'XLow', 'XHigh', 'Y', 'YLow', 'YHigh')", True, 'import deephaven.Plot as plt\n'), ((41, 7, 41, 84), 'deephaven.Plot.errorBarXYBy', 'plt.errorBarXYBy', ({(41, 24, 41, 28): '"""S1"""', (41, 30, 41, 31): 't', (41, 33, 41, 36): '"""X"""', (41, 38, 41, 44): '"""XLow"""', (41, 46, 41, 53): '"""XHigh"""', (41, 55, 41, 58): '"""Y"""', (41, 60, 41, 66): '"""YLow"""', (41, 68, 41, 75): '"""YHigh"""', (41, 77, 41, 83): '"""USym"""'}, {}), "('S1', t, 'X', 'XLow', 'XHigh', 'Y', 'YLow', 'YHigh', 'USym')", True, 'import deephaven.Plot as plt\n'), ((42, 6, 42, 55), 'deephaven.Plot.errorBarX', 'plt.errorBarX', ({(42, 20, 42, 24): '"""S1"""', (42, 26, 42, 27): 't', (42, 29, 42, 32): '"""X"""', (42, 34, 42, 40): '"""XLow"""', (42, 42, 42, 49): '"""XHigh"""', (42, 51, 42, 54): '"""Y"""'}, {}), "('S1', t, 'X', 'XLow', 'XHigh', 'Y')", True, 'import deephaven.Plot as plt\n'), ((43, 8, 43, 67), 'deephaven.Plot.errorBarXBy', 'plt.errorBarXBy', ({(43, 24, 43, 28): '"""S1"""', (43, 30, 43, 31): 't', (43, 33, 43, 36): '"""X"""', (43, 38, 43, 44): '"""XLow"""', (43, 46, 43, 53): '"""XHigh"""', (43, 55, 43, 58): '"""Y"""', (43, 60, 43, 66): '"""USym"""'}, {}), "('S1', t, 'X', 'XLow', 'XHigh', 'Y', 'USym')", True, 'import deephaven.Plot as plt\n'), ((44, 6, 44, 55), 'deephaven.Plot.errorBarY', 'plt.errorBarY', ({(44, 20, 44, 24): '"""S1"""', (44, 26, 44, 27): 't', (44, 29, 44, 32): '"""X"""', (44, 34, 44, 37): '"""Y"""', (44, 39, 44, 45): '"""YLow"""', (44, 47, 44, 54): '"""YHigh"""'}, {}), "('S1', t, 'X', 'Y', 'YLow', 'YHigh')", True, 'import deephaven.Plot as plt\n'), ((45, 8, 45, 67), 'deephaven.Plot.errorBarYBy', 'plt.errorBarYBy', ({(45, 24, 45, 28): '"""S1"""', (45, 30, 45, 31): 't', (45, 33, 45, 36): '"""X"""', (45, 38, 45, 41): '"""Y"""', (45, 43, 45, 49): '"""YLow"""', (45, 51, 45, 58): '"""YHigh"""', (45, 60, 45, 66): '"""USym"""'}, {}), "('S1', t, 'X', 'Y', 'YLow', 'YHigh', 'USym')", True, 'import deephaven.Plot as plt\n'), ((70, 5, 70, 37), 'deephaven.Plot.plot', 'plt.plot', ({(70, 14, 70, 18): '"""S1"""', (70, 20, 70, 27): 'valuesD', (70, 29, 70, 36): 'valuesI'}, {}), "('S1', valuesD, valuesI)", True, 'import deephaven.Plot as plt\n'), ((71, 5, 71, 48), 'deephaven.Plot.plot3d', 'plt.plot3d', ({(71, 16, 71, 20): '"""S1"""', (71, 22, 71, 29): 'valuesI', (71, 31, 71, 38): 'valuesI', (71, 40, 71, 47): 'valuesI'}, {}), "('S1', valuesI, valuesI, valuesI)", True, 'import deephaven.Plot as plt\n'), ((73, 6, 73, 44), 'deephaven.Plot.catPlot', 'plt.catPlot', ({(73, 18, 73, 22): '"""S1"""', (73, 24, 73, 34): 'categories', (73, 36, 73, 43): 'valuesI'}, {}), "('S1', categories, valuesI)", True, 'import deephaven.Plot as plt\n'), ((74, 7, 74, 59), 'deephaven.Plot.catPlot3d', 'plt.catPlot3d', ({(74, 21, 74, 25): '"""S1"""', (74, 27, 74, 37): 'categories', (74, 39, 74, 49): 'categories', (74, 51, 74, 58): 'valuesD'}, {}), "('S1', categories, categories, valuesD)", True, 'import deephaven.Plot as plt\n'), ((76, 7, 76, 40), 'deephaven.Plot.catHistPlot', 'plt.catHistPlot', ({(76, 23, 76, 27): '"""S1"""', (76, 29, 76, 39): 'categories'}, {}), "('S1', categories)", True, 'import deephaven.Plot as plt\n'), ((80, 6, 80, 80), 'deephaven.Plot.errorBarXY', 'plt.errorBarXY', ({(80, 21, 80, 25): '"""S1"""', (80, 27, 80, 34): 'valuesD', (80, 36, 80, 43): 'valuesD', (80, 45, 80, 52): 'valuesD', (80, 54, 80, 61): 'valuesD', (80, 63, 80, 70): 'valuesD', (80, 72, 80, 79): 'valuesD'}, {}), "('S1', valuesD, valuesD, valuesD, valuesD, valuesD, valuesD)", True, 'import deephaven.Plot as plt\n'), ((81, 7, 81, 62), 'deephaven.Plot.errorBarX', 'plt.errorBarX', ({(81, 21, 81, 25): '"""S1"""', (81, 27, 81, 34): 'valuesD', (81, 36, 81, 43): 'valuesD', (81, 45, 81, 52): 'valuesD', (81, 54, 81, 61): 'valuesD'}, {}), "('S1', valuesD, valuesD, valuesD, valuesD)", True, 'import deephaven.Plot as plt\n'), ((82, 7, 82, 62), 'deephaven.Plot.errorBarY', 'plt.errorBarY', ({(82, 21, 82, 25): '"""S1"""', (82, 27, 82, 34): 'valuesD', (82, 36, 82, 43): 'valuesD', (82, 45, 82, 52): 'valuesD', (82, 54, 82, 61): 'valuesD'}, {}), "('S1', valuesD, valuesD, valuesD, valuesD)", True, 'import deephaven.Plot as plt\n'), ((85, 5, 85, 35), 'deephaven.Plot.histPlot', 'plt.histPlot', ({(85, 18, 85, 22): '"""S1"""', (85, 24, 85, 31): 'valuesD', (85, 33, 85, 34): '5'}, {}), "('S1', valuesD, 5)", True, 'import deephaven.Plot as plt\n'), ((86, 5, 86, 42), 'deephaven.Plot.histPlot', 'plt.histPlot', ({(86, 18, 86, 22): '"""S1"""', (86, 24, 86, 31): 'valuesD', (86, 33, 86, 34): '0', (86, 36, 86, 38): '10', (86, 40, 86, 41): '5'}, {}), "('S1', valuesD, 0, 10, 5)", True, 'import deephaven.Plot as plt\n'), ((87, 5, 87, 35), 'deephaven.Plot.histPlot', 'plt.histPlot', ({(87, 18, 87, 22): '"""S1"""', (87, 24, 87, 31): 'valuesI', (87, 33, 87, 34): '5'}, {}), "('S1', valuesI, 5)", True, 'import deephaven.Plot as plt\n'), ((9, 4, 9, 31), 'deephaven.Plot.plot', 'plt.plot', ({(9, 13, 9, 17): '"""S1"""', (9, 19, 9, 20): 't', (9, 22, 9, 25): '"""X"""', (9, 27, 9, 30): '"""Y"""'}, {}), "('S1', t, 'X', 'Y')", True, 'import deephaven.Plot as plt\n'), ((21, 5, 21, 35), 'deephaven.Plot.catPlot', 'plt.catPlot', ({(21, 17, 21, 21): '"""S1"""', (21, 23, 21, 24): 't', (21, 26, 21, 29): '"""X"""', (21, 31, 21, 34): '"""Y"""'}, {}), "('S1', t, 'X', 'Y')", True, 'import deephaven.Plot as plt\n'), ((10, 5, 10, 32), 'deephaven.Plot.plot', 'plt.plot', ({(10, 14, 10, 18): '"""S1"""', (10, 20, 10, 21): 't', (10, 23, 10, 26): '"""X"""', (10, 28, 10, 31): '"""Y"""'}, {}), "('S1', t, 'X', 'Y')", True, 'import deephaven.Plot as plt\n'), ((12, 5, 12, 32), 'deephaven.Plot.plot', 'plt.plot', ({(12, 14, 12, 18): '"""S1"""', (12, 20, 12, 21): 't', (12, 23, 12, 26): '"""X"""', (12, 28, 12, 31): '"""Y"""'}, {}), "('S1', t, 'X', 'Y')", True, 'import deephaven.Plot as plt\n'), ((22, 6, 22, 36), 'deephaven.Plot.catPlot', 'plt.catPlot', ({(22, 18, 22, 22): '"""S1"""', (22, 24, 22, 25): 't', (22, 27, 22, 30): '"""X"""', (22, 32, 22, 35): '"""Y"""'}, {}), "('S1', t, 'X', 'Y')", True, 'import deephaven.Plot as plt\n'), ((24, 6, 24, 36), 'deephaven.Plot.catPlot', 'plt.catPlot', ({(24, 18, 24, 22): '"""S1"""', (24, 24, 24, 25): 't', (24, 27, 24, 30): '"""X"""', (24, 32, 24, 35): '"""Y"""'}, {}), "('S1', t, 'X', 'Y')", True, 'import deephaven.Plot as plt\n'), ((11, 5, 11, 32), 'deephaven.Plot.plot', 'plt.plot', ({(11, 14, 11, 18): '"""S1"""', (11, 20, 11, 21): 't', (11, 23, 11, 26): '"""X"""', (11, 28, 11, 31): '"""Y"""'}, {}), "('S1', t, 'X', 'Y')", True, 'import deephaven.Plot as plt\n'), ((23, 6, 23, 36), 'deephaven.Plot.catPlot', 'plt.catPlot', ({(23, 18, 23, 22): '"""S1"""', (23, 24, 23, 25): 't', (23, 27, 23, 30): '"""X"""', (23, 32, 23, 35): '"""Y"""'}, {}), "('S1', t, 'X', 'Y')", True, 'import deephaven.Plot as plt\n'), ((78, 6, 78, 18), 'deephaven.Plot.figure', 'plt.figure', ({}, {}), '()', True, 'import deephaven.Plot as plt\n'), ((58, 13, 58, 25), 'deephaven.Plot.figure', 'plt.figure', ({}, {}), '()', True, 'import deephaven.Plot as plt\n')]