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()

[((1214, 1244), 'deephaven.Plot.piePlot', 'plt.piePlot', (['"""S1"""', 't', '"""X"""', '"""Y"""'], {}), "('S1', t, 'X', 'Y')\n", (1225, 1244), True, 'import deephaven.Plot as plt\n'), ((2181, 2245), 'deephaven.Plot.ohlcPlot', 'plt.ohlcPlot', (['"""Test1"""', 't', '"""Time"""', '"""Open"""', '"""High"""', '"""Low"""', '"""Close"""'], {}), "('Test1', t, 'Time', 'Open', 'High', 'Low', 'Close')\n", (2193, 2245), True, 'import deephaven.Plot as plt\n'), ((1905, 1951), 'deephaven.TableTools.col', 'tt.col', (['"""USym"""', "['A', 'B', 'A', 'B', 'A', 'B']"], {}), "('USym', ['A', 'B', 'A', 'B', 'A', 'B'])\n", (1911, 1951), True, 'import deephaven.TableTools as tt\n'), ((1969, 1998), 'deephaven.TableTools.doubleCol', 'tt.doubleCol', (['"""Open"""', 'doubles'], {}), "('Open', doubles)\n", (1981, 1998), True, 'import deephaven.TableTools as tt\n'), ((2000, 2029), 'deephaven.TableTools.doubleCol', 'tt.doubleCol', (['"""High"""', 'doubles'], {}), "('High', doubles)\n", (2012, 2029), True, 'import deephaven.TableTools as tt\n'), ((2047, 2075), 'deephaven.TableTools.doubleCol', 'tt.doubleCol', (['"""Low"""', 'doubles'], {}), "('Low', doubles)\n", (2059, 2075), True, 'import deephaven.TableTools as tt\n'), ((2077, 2107), 'deephaven.TableTools.doubleCol', 'tt.doubleCol', (['"""Close"""', 'doubles'], {}), "('Close', doubles)\n", (2089, 2107), True, 'import deephaven.TableTools as tt\n'), ((69, 86), 'deephaven.TableTools.emptyTable', 'tt.emptyTable', (['(50)'], {}), '(50)\n', (82, 86), True, 'import deephaven.TableTools as tt\n'), ((559, 593), 'deephaven.Plot.plot3d', 'plt.plot3d', (['"""S1"""', 't', '"""X"""', '"""X"""', '"""Y"""'], {}), "('S1', t, 'X', 'X', 'Y')\n", (569, 593), True, 'import deephaven.Plot as plt\n'), ((609, 646), 'deephaven.Plot.plotBy', 'plt.plotBy', (['"""S1"""', 't', '"""X"""', '"""Y"""', '"""USym"""'], {}), "('S1', t, 'X', 'Y', 'USym')\n", (619, 646), True, 'import deephaven.Plot as plt\n'), ((660, 704), 'deephaven.Plot.plot3dBy', 'plt.plot3dBy', (['"""S1"""', 't', '"""X"""', '"""X"""', '"""Y"""', '"""USym"""'], {}), "('S1', t, 'X', 'X', 'Y', 'USym')\n", (672, 704), True, 'import deephaven.Plot as plt\n'), ((1044, 1081), 'deephaven.Plot.catPlot3d', 'plt.catPlot3d', (['"""S1"""', 't', '"""X"""', '"""X"""', '"""Y"""'], {}), "('S1', t, 'X', 'X', 'Y')\n", (1057, 1081), True, 'import deephaven.Plot as plt\n'), ((1097, 1137), 'deephaven.Plot.catPlotBy', 'plt.catPlotBy', (['"""S1"""', 't', '"""X"""', '"""Y"""', '"""USym"""'], {}), "('S1', t, 'X', 'Y', 'USym')\n", (1110, 1137), True, 'import deephaven.Plot as plt\n'), ((1153, 1200), 'deephaven.Plot.catPlot3dBy', 'plt.catPlot3dBy', (['"""S1"""', 't', '"""X"""', '"""X"""', '"""Y"""', '"""USym"""'], {}), "('S1', t, 'X', 'X', 'Y', 'USym')\n", (1168, 1200), True, 'import deephaven.Plot as plt\n'), ((1253, 1282), 'deephaven.Plot.catHistPlot', 'plt.catHistPlot', (['"""S1"""', 't', '"""X"""'], {}), "('S1', t, 'X')\n", (1268, 1282), True, 'import deephaven.Plot as plt\n'), ((1296, 1325), 'deephaven.Plot.histPlot', 'plt.histPlot', (['"""S1"""', 't', '"""X"""', '(5)'], {}), "('S1', t, 'X', 5)\n", (1308, 1325), True, 'import deephaven.Plot as plt\n'), ((1338, 1374), 'deephaven.Plot.histPlot', 'plt.histPlot', (['"""S1"""', 't', '"""X"""', '(0)', '(10)', '(5)'], {}), "('S1', t, 'X', 0, 10, 5)\n", (1350, 1374), True, 'import deephaven.Plot as plt\n'), ((1388, 1455), 'deephaven.Plot.errorBarXY', 'plt.errorBarXY', (['"""S1"""', 't', '"""X"""', '"""XLow"""', '"""XHigh"""', '"""Y"""', '"""YLow"""', '"""YHigh"""'], {}), "('S1', t, 'X', 'XLow', 'XHigh', 'Y', 'YLow', 'YHigh')\n", (1402, 1455), True, 'import deephaven.Plot as plt\n'), ((1470, 1547), 'deephaven.Plot.errorBarXYBy', 'plt.errorBarXYBy', (['"""S1"""', 't', '"""X"""', '"""XLow"""', '"""XHigh"""', '"""Y"""', '"""YLow"""', '"""YHigh"""', '"""USym"""'], {}), "('S1', t, 'X', 'XLow', 'XHigh', 'Y', 'YLow', 'YHigh', 'USym')\n", (1486, 1547), True, 'import deephaven.Plot as plt\n'), ((1561, 1610), 'deephaven.Plot.errorBarX', 'plt.errorBarX', (['"""S1"""', 't', '"""X"""', '"""XLow"""', '"""XHigh"""', '"""Y"""'], {}), "('S1', t, 'X', 'XLow', 'XHigh', 'Y')\n", (1574, 1610), True, 'import deephaven.Plot as plt\n'), ((1626, 1685), 'deephaven.Plot.errorBarXBy', 'plt.errorBarXBy', (['"""S1"""', 't', '"""X"""', '"""XLow"""', '"""XHigh"""', '"""Y"""', '"""USym"""'], {}), "('S1', t, 'X', 'XLow', 'XHigh', 'Y', 'USym')\n", (1641, 1685), True, 'import deephaven.Plot as plt\n'), ((1699, 1748), 'deephaven.Plot.errorBarY', 'plt.errorBarY', (['"""S1"""', 't', '"""X"""', '"""Y"""', '"""YLow"""', '"""YHigh"""'], {}), "('S1', t, 'X', 'Y', 'YLow', 'YHigh')\n", (1712, 1748), True, 'import deephaven.Plot as plt\n'), ((1764, 1823), 'deephaven.Plot.errorBarYBy', 'plt.errorBarYBy', (['"""S1"""', 't', '"""X"""', '"""Y"""', '"""YLow"""', '"""YHigh"""', '"""USym"""'], {}), "('S1', t, 'X', 'Y', 'YLow', 'YHigh', 'USym')\n", (1779, 1823), True, 'import deephaven.Plot as plt\n'), ((2587, 2619), 'deephaven.Plot.plot', 'plt.plot', (['"""S1"""', 'valuesD', 'valuesI'], {}), "('S1', valuesD, valuesI)\n", (2595, 2619), True, 'import deephaven.Plot as plt\n'), ((2632, 2675), 'deephaven.Plot.plot3d', 'plt.plot3d', (['"""S1"""', 'valuesI', 'valuesI', 'valuesI'], {}), "('S1', valuesI, valuesI, valuesI)\n", (2642, 2675), True, 'import deephaven.Plot as plt\n'), ((2690, 2728), 'deephaven.Plot.catPlot', 'plt.catPlot', (['"""S1"""', 'categories', 'valuesI'], {}), "('S1', categories, valuesI)\n", (2701, 2728), True, 'import deephaven.Plot as plt\n'), ((2743, 2795), 'deephaven.Plot.catPlot3d', 'plt.catPlot3d', (['"""S1"""', 'categories', 'categories', 'valuesD'], {}), "('S1', categories, categories, valuesD)\n", (2756, 2795), True, 'import deephaven.Plot as plt\n'), ((2811, 2844), 'deephaven.Plot.catHistPlot', 'plt.catHistPlot', (['"""S1"""', 'categories'], {}), "('S1', categories)\n", (2826, 2844), True, 'import deephaven.Plot as plt\n'), ((2969, 3043), 'deephaven.Plot.errorBarXY', 'plt.errorBarXY', (['"""S1"""', 'valuesD', 'valuesD', 'valuesD', 'valuesD', 'valuesD', 'valuesD'], {}), "('S1', valuesD, valuesD, valuesD, valuesD, valuesD, valuesD)\n", (2983, 3043), True, 'import deephaven.Plot as plt\n'), ((3058, 3113), 'deephaven.Plot.errorBarX', 'plt.errorBarX', (['"""S1"""', 'valuesD', 'valuesD', 'valuesD', 'valuesD'], {}), "('S1', valuesD, valuesD, valuesD, valuesD)\n", (3071, 3113), True, 'import deephaven.Plot as plt\n'), ((3128, 3183), 'deephaven.Plot.errorBarY', 'plt.errorBarY', (['"""S1"""', 'valuesD', 'valuesD', 'valuesD', 'valuesD'], {}), "('S1', valuesD, valuesD, valuesD, valuesD)\n", (3141, 3183), True, 'import deephaven.Plot as plt\n'), ((3198, 3228), 'deephaven.Plot.histPlot', 'plt.histPlot', (['"""S1"""', 'valuesD', '(5)'], {}), "('S1', valuesD, 5)\n", (3210, 3228), True, 'import deephaven.Plot as plt\n'), ((3241, 3278), 'deephaven.Plot.histPlot', 'plt.histPlot', (['"""S1"""', 'valuesD', '(0)', '(10)', '(5)'], {}), "('S1', valuesD, 0, 10, 5)\n", (3253, 3278), True, 'import deephaven.Plot as plt\n'), ((3291, 3321), 'deephaven.Plot.histPlot', 'plt.histPlot', (['"""S1"""', 'valuesI', '(5)'], {}), "('S1', valuesI, 5)\n", (3303, 3321), True, 'import deephaven.Plot as plt\n'), ((248, 275), 'deephaven.Plot.plot', 'plt.plot', (['"""S1"""', 't', '"""X"""', '"""Y"""'], {}), "('S1', t, 'X', 'Y')\n", (256, 275), True, 'import deephaven.Plot as plt\n'), ((719, 749), 'deephaven.Plot.catPlot', 'plt.catPlot', (['"""S1"""', 't', '"""X"""', '"""Y"""'], {}), "('S1', t, 'X', 'Y')\n", (730, 749), True, 'import deephaven.Plot as plt\n'), ((307, 334), 'deephaven.Plot.plot', 'plt.plot', (['"""S1"""', 't', '"""X"""', '"""Y"""'], {}), "('S1', t, 'X', 'Y')\n", (315, 334), True, 'import deephaven.Plot as plt\n'), ((480, 507), 'deephaven.Plot.plot', 'plt.plot', (['"""S1"""', 't', '"""X"""', '"""Y"""'], {}), "('S1', t, 'X', 'Y')\n", (488, 507), True, 'import deephaven.Plot as plt\n'), ((782, 812), 'deephaven.Plot.catPlot', 'plt.catPlot', (['"""S1"""', 't', '"""X"""', '"""Y"""'], {}), "('S1', t, 'X', 'Y')\n", (793, 812), True, 'import deephaven.Plot as plt\n'), ((963, 993), 'deephaven.Plot.catPlot', 'plt.catPlot', (['"""S1"""', 't', '"""X"""', '"""Y"""'], {}), "('S1', t, 'X', 'Y')\n", (974, 993), True, 'import deephaven.Plot as plt\n'), ((386, 413), 'deephaven.Plot.plot', 'plt.plot', (['"""S1"""', 't', '"""X"""', '"""Y"""'], {}), "('S1', t, 'X', 'Y')\n", (394, 413), True, 'import deephaven.Plot as plt\n'), ((865, 895), 'deephaven.Plot.catPlot', 'plt.catPlot', (['"""S1"""', 't', '"""X"""', '"""Y"""'], {}), "('S1', t, 'X', 'Y')\n", (876, 895), True, 'import deephaven.Plot as plt\n'), ((2859, 2871), 'deephaven.Plot.figure', 'plt.figure', ([], {}), '()\n', (2869, 2871), True, 'import deephaven.Plot as plt\n'), ((2260, 2272), 'deephaven.Plot.figure', 'plt.figure', ([], {}), '()\n', (2270, 2272), True, 'import deephaven.Plot as plt\n')]