diff --git a/notebook-examples/sqlnotebook-docs/duckdb.duckdb b/notebook-examples/sqlnotebook-docs/duckdb.duckdb new file mode 100644 index 0000000..8aa15d9 Binary files /dev/null and b/notebook-examples/sqlnotebook-docs/duckdb.duckdb differ diff --git a/notebook-examples/sqlnotebook-docs/logo-qstudio-195-45.png b/notebook-examples/sqlnotebook-docs/logo-qstudio-195-45.png new file mode 100644 index 0000000..38e2b4f Binary files /dev/null and b/notebook-examples/sqlnotebook-docs/logo-qstudio-195-45.png differ diff --git a/notebook-examples/sqlnotebook-docs/pages/Components/All Components.md b/notebook-examples/sqlnotebook-docs/pages/Components/All Components.md new file mode 100644 index 0000000..0f36b7a --- /dev/null +++ b/notebook-examples/sqlnotebook-docs/pages/Components/All Components.md @@ -0,0 +1,270 @@ +# Welcome to qStudio - SqlNotebooks + +If you want help there are guides located at http://www.timestored.com/qstudio/help/ + +Any feature requests etc feel free to raise on [github](https://github.com/timeseries/qstudio/issues). + +# Latest Trade Prices + +Table display can be configured using column names. See help->charts for details on format. + +```sql type="grid" server="localhost:5000" +update percbar_SD_DATABAR:percent_SD_PERCENT0 ,bid_SD_FG:((`$("#FF6666";"#66FF66";""))!`$("#222";"#222";"")) bid_SD_BG from + ([] time:.z.t-til 50; + status:50?`partial`filled; + instrument:50?`GBPUSD`USDNZD`USDCAD`CHFJPY`EURUSD; + symbol_SD_TAG:50?`UBS`C`MS`HSBC`NOMURA`DB; + price_SD_CURUSD:50?100.0; + bid:50?20.0; + bid_SD_BG:50?`$("#FF6666";"";"";"";"";"";"";"";"";"";"";"";"";"#66FF66"); + bid_SD_CODE:50?("0.xXXx";"0.XXx";"0.xxXX"); + percent_SD_PERCENT0:50?1.0 ) +``` + +# Gold vs Bitcoin 2024 + +```sql type="timeseries" server="localhost:5000" +{ walk:{ [seed;n] + r:{{ abs ((1664525*x)+1013904223) mod 4294967296}\[y-1;x]}; + prds (100+((r[seed;n]) mod 11)-5)%100}; + c:{x mod `long$00:20:00.0t}x; st:x-c; cn:`long$c%1000; + ([] time:.z.d+st+1000*til cn; gold:walk[100;cn]; bitcoin:walk[2;cn]) }[.z.t] +``` + +## Candlestick Chart + + +- The table should contain columns labelled open/high/low/close/volume. +- The table must atleast contain high/low or open/close to allow it to be drawn. + + +```sql type="candle" server="localhost:5000" +{ r:{{ abs ((1664525*x)+1013904223) mod 4294967296}\[y-1;x]}; + walk:{ [r;seed;n] prds (100+((r[seed;n]) mod 11)-5)%100}[r;;]; + c:{x mod `long$00:05:00.0t}x; st:x-c; cn:100+`long$c%1000; + t:([] time:`second$.z.d+st+1000*til cn; open:walk[9;cn]; close:walk[105;cn]); + -100 sublist update low:?[open > close;close;open]-(r[11;cn] mod 11)*0.02,high:?[open < close;close;open]+(r[44;cn] mod 11)*0.02,volume:(r[44;cn] mod 110) from t}[.z.t] +``` + +# Bar + +- The first string columns are used as category labels. +- Whatever numeric columns appear after the strings represents a separate series in the chart. + +```sql type="bar" server="localhost:5000" +([] Company:`Microsoft`Oracle`Paypal`Monero`FXC`Braint`MS`UBS; + PnL:(0.8+rand[0.2])*31847.0 13239.0 127938.0 81308.0 63047.0 13010.0 152518.0 166629.0; + Revenue:(0.9+rand[0.1])*15080.0 11300.0 34444.0 3114.0 2228.0 88.9 1113.0 41196.0 ; + Negatives:(0.95+rand[0.05])*48300.0 8400.0 34700.0 38100.0 36500.0 413.0 1788.0 11732.0 ) +``` + +# Bar Horizontal + +```sql type="bar_horizontal" server="localhost:5000" +([] Company:`Microsoft`Oracle`Paypal`Monero`FXC`Braint`MS`UBS; + PnL:(0.8+rand[0.2])*31847.0 13239.0 127938.0 81308.0 63047.0 13010.0 152518.0 166629.0; + Revenue:(0.9+rand[0.1])*15080.0 11300.0 34444.0 3114.0 2228.0 88.9 1113.0 41196.0 ; + Negatives:(0.95+rand[0.05])*48300.0 8400.0 34700.0 38100.0 36500.0 413.0 1788.0 11732.0 ) +``` + +# Stack + +- The first string columns are used as category labels. +- Whatever numeric columns appear after the strings represents a separate series in the chart. + +```sql type="stack" server="localhost:5000" +([] Company:`Microsoft`Oracle`Paypal`Monero`FXC`Braint`MS`UBS; + PnL:(0.8+rand[0.2])*31847.0 13239.0 127938.0 81308.0 63047.0 13010.0 152518.0 166629.0; + Revenue:(0.9+rand[0.1])*15080.0 11300.0 34444.0 3114.0 2228.0 88.9 1113.0 41196.0 ; + Negatives:(0.95+rand[0.05])*48300.0 8400.0 34700.0 38100.0 36500.0 413.0 1788.0 11732.0 ) +``` + +# Bar Horizontal + +```sql type="stack_horizontal" server="localhost:5000" +([] Company:`Microsoft`Oracle`Paypal`Monero`FXC`Braint`MS`UBS; + PnL:(0.8+rand[0.2])*31847.0 13239.0 127938.0 81308.0 63047.0 13010.0 152518.0 166629.0; + Revenue:(0.9+rand[0.1])*15080.0 11300.0 34444.0 3114.0 2228.0 88.9 1113.0 41196.0 ; + Negatives:(0.95+rand[0.05])*48300.0 8400.0 34700.0 38100.0 36500.0 413.0 1788.0 11732.0 ) +``` + +# Line + +- The first string columns are used as category labels. +- Whatever numeric columns appear after the strings represents a separate series in the chart. + +```sql type="line" server="localhost:5000" +([] Company:`Microsoft`Oracle`Paypal`Monero`FXC`Braint`MS`UBS; + PnL:(0.8+rand[0.2])*31847.0 13239.0 127938.0 81308.0 63047.0 13010.0 152518.0 166629.0; + Revenue:(0.9+rand[0.1])*15080.0 11300.0 34444.0 3114.0 2228.0 88.9 1113.0 41196.0 ; + Negatives:(0.95+rand[0.05])*48300.0 8400.0 34700.0 38100.0 36500.0 413.0 1788.0 11732.0 ) +``` + + +# Area + +- The first string columns are used as category labels. +- Whatever numeric columns appear after the strings represents a separate series in the chart. + +```sql type="area" server="localhost:5000" +([] Company:`Microsoft`Oracle`Paypal`Monero`FXC`Braint`MS`UBS; + PnL:(0.8+rand[0.2])*31847.0 13239.0 127938.0 81308.0 63047.0 13010.0 152518.0 166629.0; + Revenue:(0.9+rand[0.1])*15080.0 11300.0 34444.0 3114.0 2228.0 88.9 1113.0 41196.0 ; + Negatives:(0.95+rand[0.05])*48300.0 8400.0 34700.0 38100.0 36500.0 413.0 1788.0 11732.0 ) +``` + +# Pie + + - Each numeric column represents one pie chart. The title of each pie chart will be the column title. + - The segments of the pie chart use the string columns as a title where possible. If there are no string columns, row numbers are used. + +```sql type="pie" server="localhost:5000" +([] Company:`Microsoft`Oracle`Paypal`Monero`FXC`Braint`MS`UBS; + PnL:(0.8+rand[0.2])*31847.0 13239.0 127938.0 81308.0 63047.0 13010.0 152518.0 166629.0; + Revenue:(0.9+rand[0.1])*15080.0 11300.0 34444.0 3114.0 2228.0 88.9 1113.0 41196.0 ; + Negatives:(0.95+rand[0.05])*48300.0 8400.0 34700.0 38100.0 36500.0 413.0 1788.0 11732.0 ) +``` + +# Hierarchical + +## Tree + + - Starting from the left each string column is taken as one nesting level + - The first numerical column will be taken as size. + +```sql type="tree" server="localhost:5000" +([] Continent:`NA`Asia`Asia`Europe`Asia`Europe`Europe`SA`Europe`NA`Europe`Asia`Australia`Europe`NA; + TradingBloc:`US`China`Japan`EU`India`UK`EU`Brazil`EU`US`Russia`SouthKorea`Australia`EU`US; + Country:`US`China`Japan`Germany`India`UK`France`Brazil`Italy`Canada`Russia`SouthKorea`Australia`Spain`Mexico; + GDP:19.485 12.238 4.872 3.693 2.651 2.638 2.583 2.054 1.944 1.647 1.578 1.531 1.323 1.314 1.151 ) +``` + + +## TreeMap + + - Starting from the left each string column is taken as one nesting level + - The first numerical column will be taken as size. + +```sql type="treemap" server="localhost:5000". +update exports:(0.1+9?0.1)*GDP, exportsPerCapita:(0.4+9?0.1)*GDPperCapita from + ([] Country:`US`France`japan`Germany`UK`Zimbabwe`Bangladesh`Nigeria`Vietnam; + Population:(0.9+9?0.2)*313847.0 213847.0 127938.0 81308.0 63047.0 13010.0 152518.0 166629.0 87840.0 ; + GDP:(0.9+9?0.2)*15080.0 3333. 4444.0 3114.0 2228.0 9.9 113.0 196.0 104.0 ; + GDPperCapita:(0.9+9?0.2)*0.001*48300.0 37000 34700.0 38100.0 36500.0 413.0 1788.0 732.0 3359.0) +``` + + +## Sankey + + - Assuming string columns named S1,S2,S3 with a numeric column of value V. + - Each row represents one flow from the top level S1 to the leaf node S3. S1->S2->S3->V + - The first numeric column reprents the size of the flow between nodes. + - Sizes are back-propagated to the top level. + - Null can be used to represent either gaps or allow assigning value to a node that is neither an inflow nor outflow. + + +```sql type="sankey" server="localhost:5000" +([] OrderOrigin:`Internal`GUI`Web`Platform`Internal`GUI`Web`Platform`Internal`GUI`Web`Platform; + Exchange:`ICE`ICE`ICE`NYSE`NYSE`NYSE`LDN`LDN`LDN`CBE`CBE`CBE; + State:12?`New`Partial`Filled`Filled`Filled`; + v:12?20) +``` + + +## Sunburst + + - Starting from the left each string column is taken as one nesting level + - The first numerical column will be taken as size. + + +```sql type="sunburst" server="localhost:5000" +([] Continent:`NA`Asia`Asia`Europe`Asia`Europe`Europe`SA`Europe`NA`Europe`Asia`Australia`Europe`NA; + TradingBloc:`US`China`Japan`EU`India`UK`EU`Brazil`EU`US`Russia`SouthKorea`Australia`EU`US; + Country:`US`China`Japan`Germany`India`UK`France`Brazil`Italy`Canada`Russia`SouthKorea`Australia`Spain`Mexico; + GDP:19.485 12.238 4.872 3.693 2.651 2.638 2.583 2.054 1.944 1.647 1.578 1.531 1.323 1.314 1.151 ) +``` + + +## Scatter + + + - Two or more numeric columns are required. + - The values in the first column are used for the X-axis. + - The values in following columns are used for the Y-axis. Each column is displayed with a separate color. + + +```sql type="scatter" server="localhost:5000" +update exports:(0.1+9?0.1)*GDP, exportsPerCapita:(0.4+9?0.1)*GDPperCapita from + ([] Country:`US`France`japan`Germany`UK`Zimbabwe`Bangladesh`Nigeria`Vietnam; + Population:(0.9+9?0.2)*313847.0 213847.0 127938.0 81308.0 63047.0 13010.0 152518.0 166629.0 87840.0 ; + GDP:(0.9+9?0.2)*15080.0 3333. 4444.0 3114.0 2228.0 9.9 113.0 196.0 104.0 ; + GDPperCapita:(0.9+9?0.2)*0.001*48300.0 37000 34700.0 38100.0 36500.0 413.0 1788.0 732.0 3359.0) +``` + +## bubble + + - The first string columns are used as category labels. + - There must then be 3 numeric columns which are used for x-coord, y-coord, size in that order. + +```sql type="bubble" server="localhost:5000" +update exports:(0.1+9?0.1)*GDP, exportsPerCapita:(0.4+9?0.1)*GDPperCapita from + ([] Country:`US`France`japan`Germany`UK`Zimbabwe`Bangladesh`Nigeria`Vietnam; + Population:(0.9+9?0.2)*313847.0 213847.0 127938.0 81308.0 63047.0 13010.0 152518.0 166629.0 87840.0 ; + GDP:(0.9+9?0.2)*15080.0 3333. 4444.0 3114.0 2228.0 9.9 113.0 196.0 104.0 ; + GDPperCapita:(0.9+9?0.2)*0.001*48300.0 37000 34700.0 38100.0 36500.0 413.0 1788.0 732.0 3359.0) +``` + +## Heatmap + + - Each numerical column in the table becomes one column in the chart. + - The numerical values represent the shading within the chart. + +```sql type="heatmap" server="localhost:5000" +update exports:(0.1+9?0.1)*GDP, exportsPerCapita:(0.4+9?0.1)*GDPperCapita from + ([] Country:`US`France`japan`Germany`UK`Zimbabwe`Bangladesh`Nigeria`Vietnam; + Population:(0.9+9?0.2)*313847.0 213847.0 127938.0 81308.0 63047.0 13010.0 152518.0 166629.0 87840.0 ; + GDP:(0.9+9?0.2)*15080.0 3333. 4444.0 3114.0 2228.0 9.9 113.0 196.0 104.0 ; + GDPperCapita:(0.9+9?0.2)*0.001*48300.0 37000 34700.0 38100.0 36500.0 413.0 1788.0 732.0 3359.0) +``` + +## Radar + + - A radar chart requires 3 or more numeric columns to render sensibly. + - Each numeric column represents one spoke in the radar. The column titles are used as spoke titles. + - Each row in the data represents one circle withing the radar. + +```sql type="radar" server="localhost:5000" +([] portfolio:`threadneedle`diamonte; agri:100 10; realEstate:100 10; tech:0 80; growthPotential:50 100; finance:60 20) +``` + +## Calendar + + - The table should contain a date and atleast one numeric column. + - The first numeric column will be used as the value for that date. + - Dates should not be repeated. If they are the value selected is not guaranteed. + + +```sql type="calendar" server="localhost:5000" +([] dt:2023.12.31 - til 730; v:(asc 730?50)+(730?50)+730#90 80 72 83 40 2 3) +``` + +## Boxplot + + - Each numerical column in the table becomes one boxplot item in the chart. + - The min/max/median/Q1/Q3 are calculated from the raw data. + - This is inefficient as a lot more data is being passed than needed but useful for toggling an existing data set view quickly. + +```sql type="boxplot" server="localhost:5000" +([] gold:10?10; silver:til 10; crude:desc til 10; slick:13-til 10; copper:10?3; iron:10?8; diamond:4+10?8; rubber:6+10?10; lead:8+10?12) +``` + +## Metrics + + - Two or more numeric columns are required. + - The values in the first column are used for the X-axis. + - The values in following columns are used for the Y-axis. Each column is displayed with a separate color. + + +```sql type="metrics" server="localhost:5000" +([] gold:10?10; silver:til 10; crude:desc til 10; slick:13-til 10) +``` diff --git a/notebook-examples/sqlnotebook-docs/pages/Components/Time-series Charts.md b/notebook-examples/sqlnotebook-docs/pages/Components/Time-series Charts.md new file mode 100644 index 0000000..137c2ca --- /dev/null +++ b/notebook-examples/sqlnotebook-docs/pages/Components/Time-series Charts.md @@ -0,0 +1,133 @@ +--- +server: c:\temp\duckdb.duckdb +--- + +# Time-series Charts + +Time-series Charts are the best way to visualize time-series data. They can render as lines, points or bars. + +Our SQLNotebooks work with 30+ databases , the examples below use this example [duckdb-demo.duckdb](https://www.timestored.com/sqlnotebook/files/duckdb-demo.duckdb) database** +you can download it and change the server name in the header of the file to render the examples on your own machine. + +## Single Time-Series + +A result with a single time column and a single numeric column are rendered as a single area chart with latest , maximum and minimum values shown by default. + +```sql type='timeseries' +SELECT time,gold FROM gold_vs_bitcoin ORDER BY time ASC +``` + +## Multiple Time-Series + +A tabular result with multiple numeric columns is shown as one series line per numeric column. The latest values are shown as labels on the right hand side. + +```sql type='timeseries' +SELECT * FROM gold_vs_bitcoin ORDER BY time ASC +``` + +# Time-Series TAQ Chart + +Pulse has particularly good support for finance charts. The below image shows a time-series chart displaying: +See the [TAQ docs](Time-series%20TAQ) for more information. + +```sql type='timeseries' overrideJson={{"custom":{"dataZoom":{"show":true}}, grid:{bottom:70}}} +SELECT * FROM taq ORDER BY time ASC +``` + +# OverrideJSON - eCharts + +You can specify an ``overrideJSON`` argument to configure charts. For example setting custom.dataZoom.show:true would add a data control as shown above in the TAQ chart. + +## dataZoom Control + +```` +```sql type='timeseries' overrideJson={{"custom":{"dataZoom":{"show":true}}, grid:{bottom:70}}} +SELECT * FROM taq ORDER BY time ASC +``` +```` + + +# colConfig - Column Configuration + +You can specify an ``colConfig`` argument to configure how a column is displayed within a chart. + +## Dual-Axis + +```` +```sql type='timeseries' colConfig={ {bitcoin:{itemStyle:{color:'#888822' }, axisChoice:"rightax"}}} +SELECT * FROM gold_vs_bitcoin ORDER BY time ASC +``` +```` + +```sql type='timeseries' colConfig={ {bitcoin:{itemStyle:{color:'#888822' }, axisChoice:"rightax"}}} +SELECT * FROM gold_vs_bitcoin ORDER BY time ASC +``` + +## Combined Bar and Line Charts + +```` +```sql type='timeseries' colConfig={ {bitcoin:{itemStyle:{color:'#661111' }, type:"bar"}}} +SELECT * FROM gold_vs_bitcoin ORDER BY time ASC +``` +```` + +```sql type='timeseries' colConfig={ {bitcoin:{itemStyle:{color:'#661111' }, type:"bar"}}} +SELECT * FROM gold_vs_bitcoin ORDER BY time ASC +``` + +# SQL Based Configuration + +```sql type='timeseries' colConfig={ {bitcoin:{itemStyle:{color:'#661111' }, type:"bar"}}} +SELECT * FROM japan_births_deaths ORDER BY Year +``` + +```sql type='grid' colConfig={ {bitcoin:{itemStyle:{color:'#661111' }, type:"bar"}}} +SELECT * FROM japan_births_deaths ORDER BY Year +``` + + +You can configure the appearance of a column by adding an _SD_FORMATTER at the end of the column name. +For example if a column was call itemPrice, you could name it itemPrice_SD_CIRCLE to show the chart without a line and instead showing circle markers. Additionally you could add a column named: itemPrice_SD_SIZE to set the size of the circle/symbol. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
AreaExampleOptionsDescription
Shape_SD_CIRCLECIRCLE, RECT, ROUNDRECT, TRIANGLE, DIAMOND, PIN, ARROW, NONEThe shape to use for displaying points in the chart.
Shape Size_SD_SIZENumber 1-99The size of the shape to use for displaying points in the chart. You MUST have set an SD_SHAPE first.
Point Marker_SD_MARKPOINTStringAdds a labeled point to the chart at the corresponding point.
Point Line_SD_MARKLINEStringAdds a labeled vertical line to the chart at the x-axis/time location.
Point Line_SD_MARKAREAStringAdds a shaded area to the chart between when the label starts and finishes.
diff --git a/notebook-examples/sqlnotebook-docs/pages/Components/Time-series TAQ.md b/notebook-examples/sqlnotebook-docs/pages/Components/Time-series TAQ.md new file mode 100644 index 0000000..dd2713b --- /dev/null +++ b/notebook-examples/sqlnotebook-docs/pages/Components/Time-series TAQ.md @@ -0,0 +1,100 @@ +# Time-Series TAQ Chart + +Pulse has particularly good support for finance charts. The below image shows a time-series chart displaying: + + - **Bid/Ask Lines** - A two-way price quotation representing the highest price a buyer will pay for a security and the lowest price a seller will take for it. + - **Triangles** - Representing client trades, the position is the price executed at and the radius is proportional to the quantity of the trade. + - **Circles** - Represent hedger trades. To maintain an acceptable risk position given client trades. + + +```sql server='c:\temp\duckdb.duckdb' type='timeseries' overrideJson={{"custom":{"dataZoom":{"show":true}}, grid:{bottom:70}}} +SELECT * FROM taq ORDER BY time ASC +``` + +To generate such a chart, we use specially named columns to control the appearance as shown below. The table must: + + - Contain atleast one **date or time** column. + - Any plainly named columns e.g. **Bid/Ask** - will by default be rendered as a line. + - Specially named **COL_SD_SHAPE COL_SD_SIZE** - columns can be used to generate scatter points at that location with a given size. + - For example the column pair ``BUY_SD_TRIANGLE`` ``BUY_SD_SIZE`` generate the purple triangles that together represent BUY. + + +```sql server='c:\temp\duckdb.duckdb' type='grid' +SELECT * FROM taq ORDER BY time ASC +``` + +## Configuration Explained + +You can configure the appearance of a column by adding an _SD_FORMATTER at the end of the column name. +For example if a column was call itemPrice, you could name it itemPrice_SD_CIRCLE to show the chart without a line and instead showing circle markers. Additionally you could add a column named: itemPrice_SD_SIZE to set the size of the circle/symbol. + + + + + + + + + + + + + + + + + + + + + + + + +
AreaExampleOptionsDescription
Shape_SD_CIRCLECIRCLE, RECT, ROUNDRECT, TRIANGLE, DIAMOND, PIN, ARROW, NONEThe shape to use for displaying points in the chart.
Shape Size_SD_SIZENumber 1-99The size of the shape to use for displaying points in the chart. You MUST have set an SD_SHAPE first.
+ + + +## Example KDB Query + +```sql showcodeonly +// Random walk chart +{ r:{{ abs ((1664525*x)+1013904223) mod 4294967296}\[y-1;x]}; + walk:{ [r;seed;n] prds (100+((r[seed;n]) mod 11)-5)%100}[r;;]; + c:{x mod `long$00:05:00.0t}x; st:x-c; cn:100+`long$c%500; + t:([] time:.z.d+st+1000*til cn; bid:walk[100;cn]); + rnd:{[r;seed;n] (r[seed;n] mod 1000)%1000}[r;;]; + t:update ask:bid+0.1*rnd[10;cn] from t; + t:update buy_SD_CIRCLE:?[rnd[11;cn]>0.92;bid-rnd[11;cn]*0.03;0n],sell_SD_CIRCLE:?[rnd[15;cn]>0.92;ask+rnd[11;cn]*0.03;0n] from t; + t:update buy_SD_SIZE:?[null buy_SD_CIRCLE; 0n; 1+r[14;cn] mod 10],sell_SD_SIZE:?[null sell_SD_CIRCLE; 0n; 1+r[14;cn] mod 10] from t; + t:update hedger_buy_SD_TRIANGLE:?[rnd[11;cn]>0.98;bid-rnd[11;cn]*0.01;0n],hedger_sell_SD_TRIANGLE:?[rnd[15;cn]>0.98;ask+rnd[11;cn]*0.01;0n] from t; + t:update hedger_buy_SD_SIZE:?[null hedger_buy_SD_TRIANGLE; 0n; 6+r[14;cn] mod 14],hedger_sell_SD_SIZE:?[null hedger_sell_SD_TRIANGLE;0n;6+r[14;cn] mod 14] from t; + t:select time,action:0+((0^buy_SD_CIRCLE*buy_SD_SIZE)+(0^hedger_buy_SD_TRIANGLE*hedger_buy_SD_SIZE))- + ((0^sell_SD_CIRCLE*sell_SD_SIZE)+(0^hedger_sell_SD_TRIANGLE*hedger_sell_SD_SIZE)) from t; + update ulimit:150,dlimit:-150,position:sums action from t}[.z.t] + +``` + + +## Example BabelDB + +```sql showcodeonly +query_data('TIME,BID,ASK,BUY_SD_TRIANGLE,BUY_SD_SIZE,SELL_SD_TRIANGLE,SELL_SD_SIZE,HEDGER_BUY_SD_CIRCLE,HEDGER_BUY_SD_SIZE,HEDGER_SELL_SD_CIRCLE,HEDGER_SELL_SD_SIZE +2024-04-16 09:20:16.170,439.39,441.415,,,,,,,, +2024-04-16 09:20:17.171,437.7425,440.673,,,,,,,, +2024-04-16 09:20:17.175,435.009,435.537,,,,,,,, +2024-04-16 09:20:18.176,431.2073,432.236,410.51,6.6,,,,,, +2024-04-16 09:20:18.180,427.964,431.17,,,,,,, +2024-04-16 09:20:19.182,428.50,431.074,,,,,,,, +2024-04-16 09:20:19.184,429.575,433.14,,,,,,,, +2024-04-16 09:20:20.185,428.503,430.38,,,,,,,, +2024-04-16 09:20:20.187,429.032,430.833,426.22,13.28,,,,,, +2024-04-16 09:20:21.188,432.794,435.99,,,,,,, +2024-04-16 09:20:21.190,437.116,439.39,,,,,,,, +2024-04-16 09:20:22.192,440.941,445.137,,,,,,,, +2024-04-16 09:20:22.196,439.29,440.084,,,,,431.56956776713156,7.96,, +2024-04-16 09:20:23.198,438.194,439.284,,,,,,,, +2024-04-16 09:20:23.200,434.3515,435.40,,,,,,,, +2024-04-16 09:20:24.201,436.52,440.67,,,,,,,, +2024-04-16 09:20:24.203,434.3485,437.43,,,,,,,,') +``` diff --git a/notebook-examples/sqlnotebook-docs/pages/Components/grid.md b/notebook-examples/sqlnotebook-docs/pages/Components/grid.md new file mode 100644 index 0000000..e89ce4b --- /dev/null +++ b/notebook-examples/sqlnotebook-docs/pages/Components/grid.md @@ -0,0 +1,234 @@ +# Grid Component + +Both the ``grid`` and the ``table`` can display tabular data within notebooks. +The grid is useful when showing data with a large number of rows as it has a fixed height and allows paging. +The table is useful for small tables as it displays all rows as a full size HTML table. It is easier styled for printing. + +```sql server='c:\temp\duckdb.duckdb' type='grid' +SELECT time, status, instrument, symbol_SD_TAG, price_SD_CURUSD, bid, bid_SD_BG, bid_SD_CODE, percent_SD_PERCENT0, percbar_SD_DATABAR, bid_SD_FG FROM quotes ORDER BY time ASC +``` + +You can either configure: + + 1. The appearance of a **column** adding an _SD_FORMATTER at the end of the column name. + 2. The appearance of a **row** by adding specially named columns, similar to the existing. + 3. By setting grid options. + +# Simple Table + +```` +```sql server='c:\temp\duckdb.duckdb' type='grid' +SELECT Country, Population, GDP, GDPperCapita, exports, exportsPerCapita FROM country_stats_scatter +``` +```` + +```sql server='c:\temp\duckdb.duckdb' type='grid' +SELECT Country, Population, GDP, GDPperCapita, exports, exportsPerCapita FROM country_stats_scatter +``` + +## Grid Configuration Options + +| Flag | Settings | Description | +| -------- | ------- | ------- | +| pager | 'none', 'all' or a number | The number of rows shown on each page. | +| autosizeColumns | true or false | Expand the columns to fill the table width. | +| height | '150px', '50%' or any valid CSS value | The height of the grid shown. | +| showFilters | true or false | Show data filters at the top of the grid. | + +```` +```sql type='grid' pager='none' autosizeColumns={false} height="240px" showFilters={true} +FROM bank_failures +``` +```` + +```sql server='c:\temp\duckdb.duckdb' type='grid' pager='none' autosizeColumns={false} height="240px" showFilters={true} +FROM bank_failures +``` + +# Column Formatters + +Below is our per column formatters, by naming a column with the postfix on the end, you can select the formatter: + +```` +```sql server='c:\temp\duckdb.duckdb' type='grid' +SELECT Country AS Country_SD_TAG, Population AS Population_SD_NUMBER0, GDP AS GDP_SD_CURGBP, + GDPperCapita, exports, exportsPerCapita AS exportsPerCapita_SD_PERCENT0 + FROM country_stats_scatter +``` +```` + +```sql server='c:\temp\duckdb.duckdb' type='grid' +SELECT Country AS Country_SD_TAG, Population AS Population_SD_NUMBER0, GDP AS GDP_SD_CURGBP, + GDPperCapita, exports, exportsPerCapita AS exportsPerCapita_SD_PERCENT0 + FROM country_stats_scatter +``` + +## Formatter Postfixes + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
AreaExampleColumn Name PostfixOptionsDescription
Numbers0.11_SD_NUMBER00-9 Decimal places shownDisplay as a number with thousand separators and decimal places.
Percentages50%_SD_PERCENT00-9 Decimal places shownDisplay as a percentage % with thousand separators and decimal places.
Currencies$1,000.01_SD_CURUSDUSD/GBP/CCY where CCY is an ISO 4217 currency code. Display an amount in a given currency. Always showing decimal places as appropriate.
Coloured TagsLondon_SD_TAGNo options.Highlight the text with a randomly selected color based on the text. So that the same text generates the same color. + For more custom highlighting use raw html.
Status FlagsDone_SD_STATUSNo options.Highlight the text with an appropriate color based on the text content assuming the text represents a task. e.g. +
    +
  • Blue = new, open, created, ready, starting
  • +
  • Amber = runnable, waiting, partial, blocked, flagged, suspended, paused, stopping
  • +
  • Red = removed, cancelled, rejected, stopped
  • +
  • Green = terminated, resolved, closed, done, complete, filled, running
  • +
+For more custom highlighting use raw html. +
HTML_SD_HTMLDisplay the column content exactly as-is, rendering any HTML tags.
Databars██████████_SD_DATABAR Given a value between 0-1 i.e. a ratio or percent, draw it as a bar with size proportional to percentage.
Play Soundalarm_SD_SOUNDNo options.Play a sound or read the text out loud. +
    +
  • Pre-installed sounds include: alarm, bell, buzzer, kaching, sheep, siren, stockbell, trumpet, uhoh.
  • +
  • URLs beginning with http will be played if possible. e.g. https://www.timestored.com/files/goodresult.mp3
  • +
  • Text will be read out loud using the system Text To Speech
  • +
+For more information see raw html. +
+ + +# Sparklines + +```sql server='localhost:5000' type='grid' height='150px' +select v,vl_sd_sparkline:v , vb_sd_sparkbar:v , + vd_sd_sparkdiscrete:v , vbl_sd_sparkbullet:v , + vpie_sd_sparkpie:v , vbox_sd_sparkboxplot:v from + ([] a:1 2 3; v:(asc 9?1 2 3 1 9 8 7 3 -10 -28 7 3 -10 -2; 15?4 27 34 52 54 59 -4 -30 -45 52 54 59 61 68 78 82 85 87 91 93 100 ;6 6 6 6 6 -6 2 2 0)) +``` + +#### Kdb Sparklines Example Code + +```sql showcodeonly +select v,vl_sd_sparkline:v , vb_sd_sparkbar:v , + vd_sd_sparkdiscrete:v , vbl_sd_sparkbullet:v , + vpie_sd_sparkpie:v , vbox_sd_sparkboxplot:v from + ([] a:1 2 3; v:(asc 9?1 2 3 1 9 8 7 3 -10 -28 7 3 -10 -2; 15?4 27 34 52 54 59 -4 -30 -45 52 54 59 61 68 78 82 85 87 91 93 100 ;6 6 6 6 6 -6 2 2 0)) +``` + +#### H2 Database Sparklines Example SQL + +```sql showcodeonly +/* DROP table foo; */ +create table foo ( + id identity not null primary key, + nums array +); + +INSERT INTO FOO (id, nums) VALUES (1, ARRAY [1,2,3,2,-5,-6,3,1,2,5]); +INSERT INTO FOO (id, nums) VALUES (2, (4,5,6,8,9,14,18,25,10,0,-3)); +SELECT ID,NUMS AS N_SD_SPARKLINE FROM FOO; +``` + + +# Highlighting and Formatting by Row: + +**Highlighting and styling relies on having an additional column named similarly to the column you want to affect.** +For example to style a column called **itemPrice**, you could add an additional column called **itemPrice_SD_CURUSD** to show the price as a currency in US Dollars. +This allows you to customize the foreground/background and style per row. + +![Row Highlighting](https://www.timestored.com/pulse/help/img/table-example-pulse-highlight-rows.png) + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
AreaColumn Name PostfixExample ValueDescription
Background Color_SD_BG#FF0000Set the background colour of the original column. +
HTML Colors can be specified as names or values.
Foreground Color_SD_FG#FF0000Set the foreground colour of the original column. +
HTML Colors can be specified as names or values.
CSS Style Name(s)_SD_CLASSsd_cell_red sd_cell_greenSet the CSS class of the original column.
Format Code_SD_CODE0.xXXx 0.xxXX 0.xXXConfigure the number of decimal places displayed AND which of the digits are shown larger. This is useful for emphasising basis points for FX currencies etc.
\ No newline at end of file diff --git a/notebook-examples/sqlnotebook-docs/pages/Components/table.md b/notebook-examples/sqlnotebook-docs/pages/Components/table.md new file mode 100644 index 0000000..a4d474d --- /dev/null +++ b/notebook-examples/sqlnotebook-docs/pages/Components/table.md @@ -0,0 +1,219 @@ +# Table Component + +Both the ``table`` and the ``grid`` can display tabular data within notebooks. +The table is useful for small tables as it displays all rows as a full size HTML table. It is easier styled for printing. +The grid is useful when showing data with a large number of rows as it has a fixed height and allows paging. + + +```sql server='c:\temp\duckdb.duckdb' type='table' +SELECT time, status, instrument, symbol_SD_TAG, price_SD_CURUSD, bid, bid_SD_BG, bid_SD_CODE, percent_SD_PERCENT0, percbar_SD_DATABAR, bid_SD_FG FROM quotes ORDER BY time ASC LIMIT 10 +``` + +You can either configure: + + 1. The appearance of a **column** adding an _SD_FORMATTER at the end of the column name. + 2. The appearance of a **row** by adding specially named columns, similar to the existing. + 3. By setting grid options. + +# Simple Table + +```` +```sql server='c:\temp\duckdb.duckdb' type='table' +SELECT Country, Population, GDP, GDPperCapita, exports, exportsPerCapita FROM country_stats_scatter +``` +```` + +```sql server='c:\temp\duckdb.duckdb' type='table' +SELECT Country, Population, GDP, GDPperCapita, exports, exportsPerCapita FROM country_stats_scatter +``` + +# Column Formatters + +Below is our per column formatters, by naming a column with the postfix on the end, you can select the formatter: + +```` +```sql server='c:\temp\duckdb.duckdb' type='table' +SELECT Country AS Country_SD_TAG, Population AS Population_SD_NUMBER0, GDP AS GDP_SD_CURGBP, + GDPperCapita, exports, exportsPerCapita AS exportsPerCapita_SD_PERCENT0 + FROM country_stats_scatter +``` +```` + +```sql server='c:\temp\duckdb.duckdb' type='table' +SELECT Country AS Country_SD_TAG, Population AS Population_SD_NUMBER0, GDP AS GDP_SD_CURGBP, + GDPperCapita, exports, exportsPerCapita AS exportsPerCapita_SD_PERCENT0 + FROM country_stats_scatter +``` + +## Formatter Postfixes + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
AreaExampleColumn Name PostfixOptionsDescription
Numbers0.11_SD_NUMBER00-9 Decimal places shownDisplay as a number with thousand separators and decimal places.
Percentages50%_SD_PERCENT00-9 Decimal places shownDisplay as a percentage % with thousand separators and decimal places.
Currencies$1,000.01_SD_CURUSDUSD/GBP/CCY where CCY is an ISO 4217 currency code. Display an amount in a given currency. Always showing decimal places as appropriate.
Coloured TagsLondon_SD_TAGNo options.Highlight the text with a randomly selected color based on the text. So that the same text generates the same color. + For more custom highlighting use raw html.
Status FlagsDone_SD_STATUSNo options.Highlight the text with an appropriate color based on the text content assuming the text represents a task. e.g. +
    +
  • Blue = new, open, created, ready, starting
  • +
  • Amber = runnable, waiting, partial, blocked, flagged, suspended, paused, stopping
  • +
  • Red = removed, cancelled, rejected, stopped
  • +
  • Green = terminated, resolved, closed, done, complete, filled, running
  • +
+For more custom highlighting use raw html. +
HTML_SD_HTMLDisplay the column content exactly as-is, rendering any HTML tags.
Databars██████████_SD_DATABAR Given a value between 0-1 i.e. a ratio or percent, draw it as a bar with size proportional to percentage.
Play Soundalarm_SD_SOUNDNo options.Play a sound or read the text out loud. +
    +
  • Pre-installed sounds include: alarm, bell, buzzer, kaching, sheep, siren, stockbell, trumpet, uhoh.
  • +
  • URLs beginning with http will be played if possible. e.g. https://www.timestored.com/files/goodresult.mp3
  • +
  • Text will be read out loud using the system Text To Speech
  • +
+For more information see raw html. +
+ + +# Sparklines + +```sql server='localhost:5000' type='table' height='150px' +select v,vl_sd_sparkline:v , vb_sd_sparkbar:v , + vd_sd_sparkdiscrete:v , vbl_sd_sparkbullet:v , + vpie_sd_sparkpie:v , vbox_sd_sparkboxplot:v from + ([] a:1 2 3; v:(asc 9?1 2 3 1 9 8 7 3 -10 -28 7 3 -10 -2; 15?4 27 34 52 54 59 -4 -30 -45 52 54 59 61 68 78 82 85 87 91 93 100 ;6 6 6 6 6 -6 2 2 0)) +``` + +#### Kdb Sparklines Example Code + +```sql showcodeonly +select v,vl_sd_sparkline:v , vb_sd_sparkbar:v , + vd_sd_sparkdiscrete:v , vbl_sd_sparkbullet:v , + vpie_sd_sparkpie:v , vbox_sd_sparkboxplot:v from + ([] a:1 2 3; v:(asc 9?1 2 3 1 9 8 7 3 -10 -28 7 3 -10 -2; 15?4 27 34 52 54 59 -4 -30 -45 52 54 59 61 68 78 82 85 87 91 93 100 ;6 6 6 6 6 -6 2 2 0)) +``` + +#### H2 Database Sparklines Example SQL + +```sql showcodeonly +/* DROP table foo; */ +create table foo ( + id identity not null primary key, + nums array +); + +INSERT INTO FOO (id, nums) VALUES (1, ARRAY [1,2,3,2,-5,-6,3,1,2,5]); +INSERT INTO FOO (id, nums) VALUES (2, (4,5,6,8,9,14,18,25,10,0,-3)); +SELECT ID,NUMS AS N_SD_SPARKLINE FROM FOO; +``` + + +# Highlighting and Formatting by Row: + +**Highlighting and styling relies on having an additional column named similarly to the column you want to affect.** +For example to style a column called **itemPrice**, you could add an additional column called **itemPrice_SD_CURUSD** to show the price as a currency in US Dollars. +This allows you to customize the foreground/background and style per row. + + +```sql server='c:\temp\duckdb.duckdb' type='table' +FROM quotes LIMIT 10 +``` + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
AreaColumn Name PostfixExample ValueDescription
Background Color_SD_BG#FF0000Set the background colour of the original column. +
HTML Colors can be specified as names or values.
Foreground Color_SD_FG#FF0000Set the foreground colour of the original column. +
HTML Colors can be specified as names or values.
CSS Style Name(s)_SD_CLASSsd_cell_red sd_cell_greenSet the CSS class of the original column.
Format Code_SD_CODE0.xXXx 0.xxXX 0.xXXConfigure the number of decimal places displayed AND which of the digits are shown larger. This is useful for emphasising basis points for FX currencies etc.
\ No newline at end of file diff --git a/notebook-examples/sqlnotebook-docs/pages/Data Sources.md b/notebook-examples/sqlnotebook-docs/pages/Data Sources.md new file mode 100644 index 0000000..acb4797 --- /dev/null +++ b/notebook-examples/sqlnotebook-docs/pages/Data Sources.md @@ -0,0 +1,89 @@ +# Data Sources + +SQLNotebooks supports any database with a JDBC driver, this includes kdb, postgresql, mysql, ms sql, clickhouse and [30+ databases](https://www.timestored.com/qstudio/database/). +Once a connection is created it can be used within all notebooks. + +## Supported Databases + +The driver for these databases are built into the qStudio download. + + + + + + + + + + + + + + + + + + +
kdb+
mySQL
QuestDB
PostgreSQL
Redis
TimeScale
Microsoft SQL Server
H2 Database
DuckDB
Oracle
+ + + +The driver for the below databases should automatically download on first usage. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
TDengine
DolphinDB
Clickhouse
MongoDB
Druid
InfluxDB
starrocks database
StarRocks
Redshift
HSQLDB
SQLite
CSV
MS Access
JDBC
apache doris
Apache Doris
Apache Calcite Avatica
Snowflake
Elastic Search
MariaDB
Apache Kylin
DB2
SingleStore
SingleStore
Teradata
CrateDB
NuoDB
SAP HANA
Gemfire XD
Snappy Data Tibco
DataBend
DataBend
Spark Hive
Kyubi Hive
Yandex Clickhouse
Derby
Presto
Trino
Volt
Volt Active Data
Apache Solr
Apache Ignite
Omnisci
Informix
Sqream
Aurora
\ No newline at end of file diff --git a/notebook-examples/sqlnotebook-docs/pages/Database Demos/babeldb.md b/notebook-examples/sqlnotebook-docs/pages/Database Demos/babeldb.md new file mode 100644 index 0000000..000d030 --- /dev/null +++ b/notebook-examples/sqlnotebook-docs/pages/Database Demos/babeldb.md @@ -0,0 +1,499 @@ +# BabelDB + +## Query everything in one place. + +Combine queries between any JDBC compatible database or JSON/CSV/HTML data sources +For videos and more help information see [BabelDB docs](https://www.timestored.com/pulse/help/babeldb). + +# Query_web( REST/CSV/HTML ) +To query JSON/CSV/HTML based tables use query_web and BabelDB will automatically detect the format and return a table: + +```sql showcodeonly +select * from query_web('https://api3.binance.com/api/v3/ticker/price'); +query_web('https://api.github.com/search/repositories?q=more+useful+keyboard') +query_web('https://www.iso20022.org/sites/default/files/ISO10383_MIC/ISO10383_MIC.csv') +query_web('https://en.wikipedia.org/wiki/List_of_bank_failures_in_the_United_States_(2008%E2%80%93present)') +https://fred.stlouisfed.org/graph/fredgraph.csv?id=MORTGAGE30US +``` + +```sql type='treemap' server='QDUCKDB' +select Bank,"Assets ($mil.)" as Millions from query_web('https://en.wikipedia.org/wiki/List_of_bank_failures_in_the_United_States_(2008%E2%80%93present)') +``` + +# Query_data( hardcoded JSON/CSV ) + +```sql showcodeonly +query_data('Date,val +2001-01-07,88 +2001-01-08,99 +2001-01-09,55 +2001-01-10,66 +2001-01-11,70 +2001-01-12,75 +') +``` + + +## Search Trends 2024 + + +```sql server='QDUCKDB' type='timeseries' overrideJson={{grid:{top:50}}} +query_data('Week Matthew Perry chandrayaan-3 titanic submarine hurricane lee maine shooting nashville shooting Tina Turner Ken Block Lil Tay Jerry Springer Angus Cloud Nicola Bulley Jason Aldean Joe Jonas Smash Mouth Matthew Perry_SD_MARKPOINT chandrayaan-3_SD_MARKPOINT titanic submarine_SD_MARKPOINT hurricane lee_SD_MARKPOINT maine shooting_SD_MARKPOINT nashville shooting_SD_MARKPOINT Tina Turner_SD_MARKPOINT Ken Block_SD_MARKPOINT Lil Tay_SD_MARKPOINT Jerry Springer_SD_MARKPOINT Angus Cloud_SD_MARKPOINT +01/01/2023 0 0 0 0 0 0 1 32 0 0 0 0 0 0 0 Ken Block +01/08/2023 0 0 0 0 0 0 1 2 0 0 0 0 0 0 0 +01/15/2023 0 0 0 0 0 0 1 1 0 0 0 0 0 0 0 +01/22/2023 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 +01/29/2023 0 0 0 0 0 0 1 0 0 0 0 4 0 0 0 +02/05/2023 0 0 0 0 0 0 1 0 0 0 0 14 0 0 0 +02/12/2023 0 0 0 0 0 0 1 0 0 0 0 12 1 0 0 +02/19/2023 0 0 0 0 0 0 1 0 0 0 0 17 0 0 0 +02/26/2023 0 0 0 0 0 0 0 0 0 0 0 2 0 0 0 +03/05/2023 0 0 0 0 0 0 1 0 0 0 0 1 0 0 0 +03/12/2023 0 0 0 0 0 0 1 0 0 0 0 1 0 0 0 +03/19/2023 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 +03/26/2023 0 0 0 0 0 38 1 0 0 0 0 0 0 0 0 nashville shooting +04/02/2023 0 0 0 0 0 2 0 0 0 0 0 0 0 0 0 +04/09/2023 0 0 0 0 0 1 1 0 0 0 0 1 0 0 0 +04/16/2023 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +04/23/2023 0 0 0 0 0 0 0 0 0 44 0 0 0 0 0 Jerry Springer +04/30/2023 0 0 0 0 0 0 0 0 0 4 0 0 0 0 0 +05/07/2023 0 0 0 0 0 0 0 0 0 1 0 1 0 0 0 +05/14/2023 0 0 0 0 0 0 0 0 0 2 0 0 0 0 0 +05/21/2023 0 0 0 0 0 0 56 0 0 1 0 0 0 0 0 Tina Turner +05/28/2023 0 0 0 0 0 0 7 0 0 1 0 0 0 0 0 +06/04/2023 0 0 0 0 0 0 2 0 0 0 0 0 0 0 0 +06/11/2023 0 0 0 0 0 0 1 0 0 1 0 0 0 0 0 +06/18/2023 0 0 73 0 0 0 1 0 0 0 0 0 0 0 0 titanic submarine +06/25/2023 0 0 6 0 0 0 1 0 0 1 0 1 0 0 0 +07/02/2023 0 0 1 0 0 0 1 0 0 0 0 0 0 0 0 +07/09/2023 0 1 1 0 0 0 1 0 0 0 0 0 1 0 0 +07/16/2023 0 1 0 0 0 0 1 0 0 0 0 0 19 0 0 +07/23/2023 0 0 0 0 0 0 1 0 0 0 0 0 14 0 0 +07/30/2023 0 1 0 0 0 0 1 0 0 0 69 0 3 0 0 Angus Cloud +08/06/2023 0 2 0 0 0 0 1 0 40 0 3 0 2 0 0 Lil Tay +08/13/2023 0 2 0 0 0 0 1 0 2 0 1 0 1 1 0 +08/20/2023 0 100 0 0 0 0 1 0 1 0 0 0 1 0 0 chandrayaan-3 +08/27/2023 0 6 0 0 0 0 0 0 0 0 0 0 1 0 0 +09/03/2023 0 3 0 17 0 0 0 0 0 0 0 0 1 14 12 17 +09/10/2023 0 2 0 24 0 0 0 0 0 0 0 0 1 3 1 hurricane lee +09/17/2023 0 2 0 2 0 0 0 0 0 0 2 0 1 3 0 +09/24/2023 0 2 0 0 0 0 0 0 1 0 1 0 1 2 0 +10/01/2023 0 1 0 0 0 0 1 0 6 0 0 0 1 1 0 +10/08/2023 0 1 0 0 0 0 0 0 1 0 0 0 0 1 0 +10/15/2023 0 1 0 0 0 0 1 0 1 0 0 0 0 1 0 +10/22/2023 0 1 0 0 29 0 0 0 0 0 0 0 0 0 0 maine shooting +10/29/2023 100 0 0 0 2 0 1 0 0 0 0 0 0 0 0 Matthew Perry +11/05/2023 7 0 0 0 0 0 1 0 0 0 0 0 0 1 0 +11/12/2023 3 0 0 0 0 0 1 0 0 0 0 0 0 0 0 +11/19/2023 2 0 0 0 0 0 1 0 0 0 0 0 0 0 0 +11/26/2023 1 0 0 0 0 0 1 0 0 0 0 0 0 0 0 +12/03/2023 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +') +``` + +# Population Trends + +## Niger Population + +```sql type='stack_horizontal' server='QDUCKDB' +/* https://www.census.gov/data-tools/demo/idb/ */ +select + Age, + CASE WHEN malesconfigured using column names. + +```sql type="grid" +SELECT * FROM quotes; +``` + +# Time-series - Gold vs Bitcoin 2024 + +```sql type="timeseries" +SELECT * FROM gold_vs_bitcoin +``` + + +## Search Trends 2024 + + +```sql server='QDUCKDB' type='timeseries' overrideJson={{grid:{top:50}}} +SELECT * FROM search_trends +``` + +# Population Trends + +## Niger Population + +```sql type='stack_horizontal' server='c:\temp\duckdb.duckdb' +/* https://www.census.gov/data-tools/demo/idb/ */ +select + Age, + CASE WHEN malesS2->S3->V + - The first numeric column reprents the size of the flow between nodes. + - Sizes are back-propagated to the top level. + - Null can be used to represent either gaps or allow assigning value to a node that is neither an inflow nor outflow. + + +```sql type="sankey" +SELECT * FROM sankey +``` + + +## Sunburst + + - Starting from the left each string column is taken as one nesting level + - The first numerical column will be taken as size. + + +```sql type="sunburst" +SELECT * FROM country_stats_scatter +``` + + +## Scatter + + + - Two or more numeric columns are required. + - The values in the first column are used for the X-axis. + - The values in following columns are used for the Y-axis. Each column is displayed with a separate color. + + +```sql type="scatter" +FROM country_stats_scatter +``` + +## bubble + + - The first string columns are used as category labels. + - There must then be 3 numeric columns which are used for x-coord, y-coord, size in that order. + +```sql type="bubble" +FROM country_stats_scatter +``` + +## Heatmap + + - Each numerical column in the table becomes one column in the chart. + - The numerical values represent the shading within the chart. + +```sql type="heatmap" +FROM country_stats_scatter +``` + +## Radar + + - A radar chart requires 3 or more numeric columns to render sensibly. + - Each numeric column represents one spoke in the radar. The column titles are used as spoke titles. + - Each row in the data represents one circle withing the radar. + +```sql type="radar" +FROM radar +``` + +## Calendar + + - The table should contain a date and atleast one numeric column. + - The first numeric column will be used as the value for that date. + - Dates should not be repeated. If they are the value selected is not guaranteed. + + +```sql type="calendar" height="500" +FROM calendar +``` + +## Boxplot + + - Each numerical column in the table becomes one boxplot item in the chart. + - The min/max/median/Q1/Q3 are calculated from the raw data. + - This is inefficient as a lot more data is being passed than needed but useful for toggling an existing data set view quickly. + +```sql type="boxplot" +SELECT * FROM boxplot +``` + +## Metrics + + - Two or more numeric columns are required. + - The values in the first column are used for the X-axis. + - The values in following columns are used for the Y-axis. Each column is displayed with a separate color. + + +```sql type="metrics" +SELECT * FROM metrics +``` + diff --git a/notebook-examples/sqlnotebook-docs/pages/Database Demos/kdb+ All.md b/notebook-examples/sqlnotebook-docs/pages/Database Demos/kdb+ All.md new file mode 100644 index 0000000..cd6416c --- /dev/null +++ b/notebook-examples/sqlnotebook-docs/pages/Database Demos/kdb+ All.md @@ -0,0 +1,267 @@ +# kdb+ SqlNotebooks + +QStudio has particularly strong support for kdb+. +Examples of in-memory queries using kdb+ for every chart type are shown below. + +# Latest Trade Prices + +```sql type="grid" server="localhost:5000" +update percbar_SD_DATABAR:percent_SD_PERCENT0 ,bid_SD_FG:((`$("#FF6666";"#66FF66";""))!`$("#222";"#222";"")) bid_SD_BG from + ([] time:.z.t-til 50; + status:50?`partial`filled; + instrument:50?`GBPUSD`USDNZD`USDCAD`CHFJPY`EURUSD; + symbol_SD_TAG:50?`UBS`C`MS`HSBC`NOMURA`DB; + price_SD_CURUSD:50?100.0; + bid:50?20.0; + bid_SD_BG:50?`$("#FF6666";"";"";"";"";"";"";"";"";"";"";"";"";"#66FF66"); + bid_SD_CODE:50?("0.xXXx";"0.XXx";"0.xxXX"); + percent_SD_PERCENT0:50?1.0 ) +``` + +# Gold vs Bitcoin 2024 + +```sql type="timeseries" server="localhost:5000" +{ walk:{ [seed;n] + r:{{ abs ((1664525*x)+1013904223) mod 4294967296}\[y-1;x]}; + prds (100+((r[seed;n]) mod 11)-5)%100}; + c:{x mod `long$00:20:00.0t}x; st:x-c; cn:`long$c%1000; + ([] time:.z.d+st+1000*til cn; gold:walk[100;cn]; bitcoin:walk[2;cn]) }[.z.t] +``` + +## Candlestick Chart + + +- The table should contain columns labelled open/high/low/close/volume. +- The table must atleast contain high/low or open/close to allow it to be drawn. + + +```sql type="candle" server="localhost:5000" +{ r:{{ abs ((1664525*x)+1013904223) mod 4294967296}\[y-1;x]}; + walk:{ [r;seed;n] prds (100+((r[seed;n]) mod 11)-5)%100}[r;;]; + c:{x mod `long$00:05:00.0t}x; st:x-c; cn:100+`long$c%1000; + t:([] time:`second$.z.d+st+1000*til cn; open:walk[9;cn]; close:walk[105;cn]); + -100 sublist update low:?[open > close;close;open]-(r[11;cn] mod 11)*0.02,high:?[open < close;close;open]+(r[44;cn] mod 11)*0.02,volume:(r[44;cn] mod 110) from t}[.z.t] +``` + +# Bar + +- The first string columns are used as category labels. +- Whatever numeric columns appear after the strings represents a separate series in the chart. + +```sql type="bar" server="localhost:5000" +([] Company:`Microsoft`Oracle`Paypal`Monero`FXC`Braint`MS`UBS; + PnL:(0.8+rand[0.2])*31847.0 13239.0 127938.0 81308.0 63047.0 13010.0 152518.0 166629.0; + Revenue:(0.9+rand[0.1])*15080.0 11300.0 34444.0 3114.0 2228.0 88.9 1113.0 41196.0 ; + Negatives:(0.95+rand[0.05])*48300.0 8400.0 34700.0 38100.0 36500.0 413.0 1788.0 11732.0 ) +``` + +# Bar Horizontal + +```sql type="bar_horizontal" server="localhost:5000" +([] Company:`Microsoft`Oracle`Paypal`Monero`FXC`Braint`MS`UBS; + PnL:(0.8+rand[0.2])*31847.0 13239.0 127938.0 81308.0 63047.0 13010.0 152518.0 166629.0; + Revenue:(0.9+rand[0.1])*15080.0 11300.0 34444.0 3114.0 2228.0 88.9 1113.0 41196.0 ; + Negatives:(0.95+rand[0.05])*48300.0 8400.0 34700.0 38100.0 36500.0 413.0 1788.0 11732.0 ) +``` + +# Stack + +- The first string columns are used as category labels. +- Whatever numeric columns appear after the strings represents a separate series in the chart. + +```sql type="stack" server="localhost:5000" +([] Company:`Microsoft`Oracle`Paypal`Monero`FXC`Braint`MS`UBS; + PnL:(0.8+rand[0.2])*31847.0 13239.0 127938.0 81308.0 63047.0 13010.0 152518.0 166629.0; + Revenue:(0.9+rand[0.1])*15080.0 11300.0 34444.0 3114.0 2228.0 88.9 1113.0 41196.0 ; + Negatives:(0.95+rand[0.05])*48300.0 8400.0 34700.0 38100.0 36500.0 413.0 1788.0 11732.0 ) +``` + +# Bar Horizontal + +```sql type="stack_horizontal" server="localhost:5000" +([] Company:`Microsoft`Oracle`Paypal`Monero`FXC`Braint`MS`UBS; + PnL:(0.8+rand[0.2])*31847.0 13239.0 127938.0 81308.0 63047.0 13010.0 152518.0 166629.0; + Revenue:(0.9+rand[0.1])*15080.0 11300.0 34444.0 3114.0 2228.0 88.9 1113.0 41196.0 ; + Negatives:(0.95+rand[0.05])*48300.0 8400.0 34700.0 38100.0 36500.0 413.0 1788.0 11732.0 ) +``` + +# Line + +- The first string columns are used as category labels. +- Whatever numeric columns appear after the strings represents a separate series in the chart. + +```sql type="line" server="localhost:5000" +([] Company:`Microsoft`Oracle`Paypal`Monero`FXC`Braint`MS`UBS; + PnL:(0.8+rand[0.2])*31847.0 13239.0 127938.0 81308.0 63047.0 13010.0 152518.0 166629.0; + Revenue:(0.9+rand[0.1])*15080.0 11300.0 34444.0 3114.0 2228.0 88.9 1113.0 41196.0 ; + Negatives:(0.95+rand[0.05])*48300.0 8400.0 34700.0 38100.0 36500.0 413.0 1788.0 11732.0 ) +``` + + +# Area + +- The first string columns are used as category labels. +- Whatever numeric columns appear after the strings represents a separate series in the chart. + +```sql type="area" server="localhost:5000" +([] Company:`Microsoft`Oracle`Paypal`Monero`FXC`Braint`MS`UBS; + PnL:(0.8+rand[0.2])*31847.0 13239.0 127938.0 81308.0 63047.0 13010.0 152518.0 166629.0; + Revenue:(0.9+rand[0.1])*15080.0 11300.0 34444.0 3114.0 2228.0 88.9 1113.0 41196.0 ; + Negatives:(0.95+rand[0.05])*48300.0 8400.0 34700.0 38100.0 36500.0 413.0 1788.0 11732.0 ) +``` + +# Pie + + - Each numeric column represents one pie chart. The title of each pie chart will be the column title. + - The segments of the pie chart use the string columns as a title where possible. If there are no string columns, row numbers are used. + +```sql type="pie" server="localhost:5000" +([] Company:`Microsoft`Oracle`Paypal`Monero`FXC`Braint`MS`UBS; + PnL:(0.8+rand[0.2])*31847.0 13239.0 127938.0 81308.0 63047.0 13010.0 152518.0 166629.0; + Revenue:(0.9+rand[0.1])*15080.0 11300.0 34444.0 3114.0 2228.0 88.9 1113.0 41196.0 ; + Negatives:(0.95+rand[0.05])*48300.0 8400.0 34700.0 38100.0 36500.0 413.0 1788.0 11732.0 ) +``` + +# Hierarchical + +## Tree + + - Starting from the left each string column is taken as one nesting level + - The first numerical column will be taken as size. + +```sql type="tree" server="localhost:5000" +([] Continent:`NA`Asia`Asia`Europe`Asia`Europe`Europe`SA`Europe`NA`Europe`Asia`Australia`Europe`NA; + TradingBloc:`US`China`Japan`EU`India`UK`EU`Brazil`EU`US`Russia`SouthKorea`Australia`EU`US; + Country:`US`China`Japan`Germany`India`UK`France`Brazil`Italy`Canada`Russia`SouthKorea`Australia`Spain`Mexico; + GDP:19.485 12.238 4.872 3.693 2.651 2.638 2.583 2.054 1.944 1.647 1.578 1.531 1.323 1.314 1.151 ) +``` + + +## TreeMap + + - Starting from the left each string column is taken as one nesting level + - The first numerical column will be taken as size. + +```sql type="treemap" server="localhost:5000" +update exports:(0.1+9?0.1)*GDP, exportsPerCapita:(0.4+9?0.1)*GDPperCapita from + ([] Country:`US`France`japan`Germany`UK`Zimbabwe`Bangladesh`Nigeria`Vietnam; + Population:(0.9+9?0.2)*313847.0 213847.0 127938.0 81308.0 63047.0 13010.0 152518.0 166629.0 87840.0 ; + GDP:(0.9+9?0.2)*15080.0 3333. 4444.0 3114.0 2228.0 9.9 113.0 196.0 104.0 ; + GDPperCapita:(0.9+9?0.2)*0.001*48300.0 37000 34700.0 38100.0 36500.0 413.0 1788.0 732.0 3359.0) +``` + + +## Sankey + + - Assuming string columns named S1,S2,S3 with a numeric column of value V. + - Each row represents one flow from the top level S1 to the leaf node S3. S1->S2->S3->V + - The first numeric column reprents the size of the flow between nodes. + - Sizes are back-propagated to the top level. + - Null can be used to represent either gaps or allow assigning value to a node that is neither an inflow nor outflow. + + +```sql type="sankey" server="localhost:5000" +([] OrderOrigin:`Internal`GUI`Web`Platform`Internal`GUI`Web`Platform`Internal`GUI`Web`Platform; + Exchange:`ICE`ICE`ICE`NYSE`NYSE`NYSE`LDN`LDN`LDN`CBE`CBE`CBE; + State:12?`New`Partial`Filled`Filled`Filled`; + v:12?20) +``` + + +## Sunburst + + - Starting from the left each string column is taken as one nesting level + - The first numerical column will be taken as size. + + +```sql type="sunburst" server="localhost:5000" +([] Continent:`NA`Asia`Asia`Europe`Asia`Europe`Europe`SA`Europe`NA`Europe`Asia`Australia`Europe`NA; + TradingBloc:`US`China`Japan`EU`India`UK`EU`Brazil`EU`US`Russia`SouthKorea`Australia`EU`US; + Country:`US`China`Japan`Germany`India`UK`France`Brazil`Italy`Canada`Russia`SouthKorea`Australia`Spain`Mexico; + GDP:19.485 12.238 4.872 3.693 2.651 2.638 2.583 2.054 1.944 1.647 1.578 1.531 1.323 1.314 1.151 ) +``` + + +## Scatter + + + - Two or more numeric columns are required. + - The values in the first column are used for the X-axis. + - The values in following columns are used for the Y-axis. Each column is displayed with a separate color. + + +```sql type="scatter" server="localhost:5000" +update exports:(0.1+9?0.1)*GDP, exportsPerCapita:(0.4+9?0.1)*GDPperCapita from + ([] Country:`US`France`japan`Germany`UK`Zimbabwe`Bangladesh`Nigeria`Vietnam; + Population:(0.9+9?0.2)*313847.0 213847.0 127938.0 81308.0 63047.0 13010.0 152518.0 166629.0 87840.0 ; + GDP:(0.9+9?0.2)*15080.0 3333. 4444.0 3114.0 2228.0 9.9 113.0 196.0 104.0 ; + GDPperCapita:(0.9+9?0.2)*0.001*48300.0 37000 34700.0 38100.0 36500.0 413.0 1788.0 732.0 3359.0) +``` + +## bubble + + - The first string columns are used as category labels. + - There must then be 3 numeric columns which are used for x-coord, y-coord, size in that order. + +```sql type="bubble" server="localhost:5000" +update exports:(0.1+9?0.1)*GDP, exportsPerCapita:(0.4+9?0.1)*GDPperCapita from + ([] Country:`US`France`japan`Germany`UK`Zimbabwe`Bangladesh`Nigeria`Vietnam; + Population:(0.9+9?0.2)*313847.0 213847.0 127938.0 81308.0 63047.0 13010.0 152518.0 166629.0 87840.0 ; + GDP:(0.9+9?0.2)*15080.0 3333. 4444.0 3114.0 2228.0 9.9 113.0 196.0 104.0 ; + GDPperCapita:(0.9+9?0.2)*0.001*48300.0 37000 34700.0 38100.0 36500.0 413.0 1788.0 732.0 3359.0) +``` + +## Heatmap + + - Each numerical column in the table becomes one column in the chart. + - The numerical values represent the shading within the chart. + +```sql type="heatmap" server="localhost:5000" +update exports:(0.1+9?0.1)*GDP, exportsPerCapita:(0.4+9?0.1)*GDPperCapita from + ([] Country:`US`France`japan`Germany`UK`Zimbabwe`Bangladesh`Nigeria`Vietnam; + Population:(0.9+9?0.2)*313847.0 213847.0 127938.0 81308.0 63047.0 13010.0 152518.0 166629.0 87840.0 ; + GDP:(0.9+9?0.2)*15080.0 3333. 4444.0 3114.0 2228.0 9.9 113.0 196.0 104.0 ; + GDPperCapita:(0.9+9?0.2)*0.001*48300.0 37000 34700.0 38100.0 36500.0 413.0 1788.0 732.0 3359.0) +``` + +## Radar + + - A radar chart requires 3 or more numeric columns to render sensibly. + - Each numeric column represents one spoke in the radar. The column titles are used as spoke titles. + - Each row in the data represents one circle withing the radar. + +```sql type="radar" server="localhost:5000" +([] portfolio:`threadneedle`diamonte; agri:100 10; realEstate:100 10; tech:0 80; growthPotential:50 100; finance:60 20) +``` + +## Calendar + + - The table should contain a date and atleast one numeric column. + - The first numeric column will be used as the value for that date. + - Dates should not be repeated. If they are the value selected is not guaranteed. + + +```sql type="calendar" server="localhost:5000" +([] dt:2023.12.31 - til 730; v:(asc 730?50)+(730?50)+730#90 80 72 83 40 2 3) +``` + +## Boxplot + + - Each numerical column in the table becomes one boxplot item in the chart. + - The min/max/median/Q1/Q3 are calculated from the raw data. + - This is inefficient as a lot more data is being passed than needed but useful for toggling an existing data set view quickly. + +```sql type="boxplot" server="localhost:5000" +([] gold:10?10; silver:til 10; crude:desc til 10; slick:13-til 10; copper:10?3; iron:10?8; diamond:4+10?8; rubber:6+10?10; lead:8+10?12) +``` + +## Metrics + + - Two or more numeric columns are required. + - The values in the first column are used for the X-axis. + - The values in following columns are used for the Y-axis. Each column is displayed with a separate color. + + +```sql type="metrics" server="localhost:5000" +([] gold:10?10; silver:til 10; crude:desc til 10; slick:13-til 10) +``` diff --git a/notebook-examples/sqlnotebook-docs/pages/Database Demos/kdb+ Simple.md b/notebook-examples/sqlnotebook-docs/pages/Database Demos/kdb+ Simple.md new file mode 100644 index 0000000..612d048 --- /dev/null +++ b/notebook-examples/sqlnotebook-docs/pages/Database Demos/kdb+ Simple.md @@ -0,0 +1,135 @@ +# kdb+ SqlNotebooks - Simple Examples + +SqlNotebooks have particularly strong support for kdb+. +Examples of in-memory queries using kdb+ for most chart types are shown below. + +## Example Time Series Charts + +```sql type="timeseries" server="localhost:5000" +([] dt:2013.01.01+til 21; cosineWave:cos a; sineWave:sin a:0.6*til 21) +``` + +```sql type="timeseries" server="localhost:5000" +([] time:10:00t+60000*til 99; Position:0.4*a-mod[a;8]; Cost:a:100*sin 0.015*til 99) +``` + +## Bar / Stack + +```sql type="bar" server="localhost:5000" +([Month:2000.01m + til 12] + Costs:30.0 40.0 45.0 55.0 58.0 63.0 55.0 65.0 78.0 80.0 75.0 90.0 ; + Sales:10.0 12.0 14.0 18.0 26.0 42.0 74.0 90.0 110.0 130.0 155.0 167.0 ) +``` + +### Bar Horizontal + +```sql type="bar_horizontal" server="localhost:5000" +([Month:2000.01m + til 12] + Costs:30.0 40.0 45.0 55.0 58.0 63.0 55.0 65.0 78.0 80.0 75.0 90.0 ; + Sales:10.0 12.0 14.0 18.0 26.0 42.0 74.0 90.0 110.0 130.0 155.0 167.0 ) +``` + +### Stack + +```sql type="stack" server="localhost:5000" +([Month:2000.01m + til 12] + Costs:30.0 40.0 45.0 55.0 58.0 63.0 55.0 65.0 78.0 80.0 75.0 90.0 ; + Sales:10.0 12.0 14.0 18.0 26.0 42.0 74.0 90.0 110.0 130.0 155.0 167.0 ) +``` + +### Stack Horizontal + +```sql type="stack_horizontal" server="localhost:5000" +([Month:2000.01m + til 12] + Costs:30.0 40.0 45.0 55.0 58.0 63.0 55.0 65.0 78.0 80.0 75.0 90.0 ; + Sales:10.0 12.0 14.0 18.0 26.0 42.0 74.0 90.0 110.0 130.0 155.0 167.0 ) +``` + +### Multiple Bar Series + +```sql type="bar" server="localhost:5000" +([] Continent:`NorthAmerica`Asia`Asia`Europe`Europe`Africa`Asia`Africa`Asia; + Country:`US`China`japan`Germany`UK`Zimbabwe`Bangladesh`Nigeria`Vietnam; + Population:313847.0 1343239.0 127938.0 81308.0 63047.0 13010.0 152518.0 166629.0 87840.0 ; + GDP:15080.0 11300.0 4444.0 3114.0 2228.0 9.9 113.0 196.0 104.0 ; + GDPperCapita:48300.0 8400.0 34700.0 38100.0 36500.0 413.0 1788.0 732.0 3359.0 ; + LifeExpectancy:77.14 72.22 80.93 78.42 78.16 39.01 61.33 51.01 70.05 ) +``` + +## Line / Area Chart + +### Line + +```sql type="line" server="localhost:5000" +([Month:2000.01m + til 12] + Costs:30.0 40.0 45.0 55.0 58.0 63.0 55.0 65.0 78.0 80.0 75.0 90.0 ; + Sales:10.0 12.0 14.0 18.0 26.0 42.0 74.0 90.0 110.0 130.0 155.0 167.0 ) +``` + +### Area + +```sql type="area" server="localhost:5000" +([Month:2000.01m + til 12] + Costs:30.0 40.0 45.0 55.0 58.0 63.0 55.0 65.0 78.0 80.0 75.0 90.0 ; + Sales:10.0 12.0 14.0 18.0 26.0 42.0 74.0 90.0 110.0 130.0 155.0 167.0 ) +``` + + +## Scatter + +```sql type="scatter" server="localhost:5000" +update GDPperCapita%20 from ([] Continent:`NorthAmerica`Asia`Asia`Europe`Europe`Africa`Asia`Africa`Asia; + Country:`US`China`japan`Germany`UK`Zimbabwe`Bangladesh`Nigeria`Vietnam; + Population:313847.0 1343239.0 127938.0 81308.0 63047.0 13010.0 152518.0 166629.0 87840.0 ; + GDP:15080.0 11300.0 4444.0 3114.0 2228.0 9.9 113.0 196.0 104.0 ; + GDPperCapita:48300.0 8400.0 34700.0 38100.0 36500.0 413.0 1788.0 732.0 3359.0 ; + LifeExpectancy:77.14 72.22 80.93 78.42 78.16 39.01 61.33 51.01 70.05 ) +``` + +## Bubble Chart + +The first numeric column is x-axis, 2nd is y-axis, 3rd is bubble size. Strings are used as labels. + +```sql type="bubble" server="localhost:5000" +update exports:(0.1+9?0.1)*GDP, exportsPerCapita:(0.4+9?0.1)*GDPperCapita from + ([] Country:`US`France`japan`Germany`UK`Zimbabwe`Bangladesh`Nigeria`Vietnam; + Population:(0.9+9?0.2)*313847.0 213847.0 127938.0 81308.0 63047.0 13010.0 152518.0 166629.0 87840.0 ; + GDP:(0.9+9?0.2)*15080.0 3333. 4444.0 3114.0 2228.0 9.9 113.0 196.0 104.0 ; + GDPperCapita:(0.9+9?0.2)*0.001*48300.0 37000 34700.0 38100.0 36500.0 413.0 1788.0 732.0 3359.0) +``` + +## Candlestick Chart + +```sql type="candle" server="localhost:5000" +([] t:09:00t+600000*til 22; high:c+30; low:c-20; open:60+til 22; close:c:55+2*til 22; volume:22#3 9 6) +``` + +## Heatmap + +```sql type="heatmap" server="localhost:5000" +([] Continent:`NorthAmerica`Asia`Asia`Europe`Europe`Africa`Asia`Africa`Asia; + Country:`US`China`japan`Germany`UK`Zimbabwe`Bangladesh`Nigeria`Vietnam; + Population:313847.0 1343239.0 127938.0 81308.0 63047.0 13010.0 152518.0 166629.0 87840.0 ; + GDP:15080.0 11300.0 4444.0 3114.0 2228.0 9.9 113.0 196.0 104.0 ; + GDPperCapita:48300.0 8400.0 34700.0 38100.0 36500.0 413.0 1788.0 732.0 3359.0 ; + LifeExpectancy:77.14 72.22 80.93 78.42 78.16 39.01 61.33 51.01 70.05 ) +``` + +## PieChart +```sql type="pie" server="localhost:5000" +([] Country:`US`China`japan`Germany`UK`Zimbabwe`Bangladesh`Nigeria`Vietnam; + GDP:15080.0 11300.0 4444.0 3114.0 2228.0 9.9 113.0 196.0 104.0 ) +``` + +### Many Pies + +```sql type="pie" server="localhost:5000" +([] Continent:`NorthAmerica`Asia`Asia`Europe`Europe`Africa`Asia`Africa`Asia; + Country:`US`China`japan`Germany`UK`Zimbabwe`Bangladesh`Nigeria`Vietnam; + Population:313847.0 1343239.0 127938.0 81308.0 63047.0 13010.0 152518.0 166629.0 87840.0 ; + GDP:15080.0 11300.0 4444.0 3114.0 2228.0 9.9 113.0 196.0 104.0 ; + GDPperCapita:48300.0 8400.0 34700.0 38100.0 36500.0 413.0 1788.0 732.0 3359.0 ; + LifeExpectancy:77.14 72.22 80.93 78.42 78.16 39.01 61.33 51.01 70.05 ) +``` + + diff --git a/notebook-examples/sqlnotebook-docs/pages/concepts/Markdown Blocks.md b/notebook-examples/sqlnotebook-docs/pages/concepts/Markdown Blocks.md new file mode 100644 index 0000000..9e9566e --- /dev/null +++ b/notebook-examples/sqlnotebook-docs/pages/concepts/Markdown Blocks.md @@ -0,0 +1,113 @@ +# Markdown Support + +SqlNotebooks supports a wide range of markdown notation as shown below. + +# h1 Heading +## h2 Heading +### h3 Heading +#### h4 Heading +##### h5 Heading +###### h6 Heading + +## Emphasis + +**This is bold text** + +__This is bold text__ + +*This is italic text* + +_This is italic text_ + +~~Strikethrough~~ + + +## Horizontal Rules + +___ + +--- + +*** + + +## Blockquotes + + +> Blockquotes can also be nested... +>> ...by using additional greater-than signs right next to each other... +> > > ...or with spaces between arrows. + + +## Lists + +Unordered + ++ Create a list by starting a line with `+`, `-`, or `*` ++ Sub-lists are made by indenting 2 spaces: + - Marker character change forces new list start: + * Ac tristique libero volutpat at + + Facilisis in pretium nisl aliquet + - Nulla volutpat aliquam velit ++ Very easy! + +Ordered + +1. Lorem ipsum dolor sit amet +2. Consectetur adipiscing elit +3. Integer molestie lorem at massa + + +1. You can use sequential numbers... +1. ...or keep all the numbers as `1.` + +Start numbering with offset: + +57. foo +1. bar + + +## Code + +Inline `code` + +Indented code + + // Some comments + line 1 of code + line 2 of code + line 3 of code + +## Tables + +| Option | Description | +| ------ | ----------- | +| data | path to data files to supply the data that will be passed into templates. | +| engine | engine to be used for processing templates. Handlebars is the default. | +| ext | extension to be used for dest files. | + +Right aligned columns + +| Option | Description | +| ------:| -----------:| +| data | path to data files to supply the data that will be passed into templates. | +| engine | engine to be used for processing templates. Handlebars is the default. | +| ext | extension to be used for dest files. | + + +## Links + +[link text](https://github.com/timestored/) + +[link with title](https://github.com/timestored/ "title text!") + +Autoconverted link https://github.com/timestored/ + + +## Images + +![Logo](https://www.timestored.com/img/logo.png) + + +[![qStudio](https://www.timestored.com/img/logo-qstudio-text.png "The qStudio")](https://www.timestored.com/qstudio) + diff --git a/notebook-examples/sqlnotebook-docs/pages/concepts/Pages.md b/notebook-examples/sqlnotebook-docs/pages/concepts/Pages.md new file mode 100644 index 0000000..aebf846 --- /dev/null +++ b/notebook-examples/sqlnotebook-docs/pages/concepts/Pages.md @@ -0,0 +1,13 @@ +# Pages + +# QStudio + +Each markdown file within the root folder/pages becomes a page. +By default qStudio launches the webpage at: http://localhost:8088/ . +Pages can be nested within folders to any reasonable depth. + +For example: + + - ``pages/index.md`` would be accessible as ``http://localhost:8088/markdown/``. + - ``pages/company/pnl.md`` would be accessible as ``http://localhost:8088/markdown/pages/company/pnl``. + - ``pages/company/index.md`` would be accessible as ``http://localhost:8088/markdown/company``. \ No newline at end of file diff --git a/notebook-examples/sqlnotebook-docs/pages/concepts/Sql Blocks.md b/notebook-examples/sqlnotebook-docs/pages/concepts/Sql Blocks.md new file mode 100644 index 0000000..912dc4c --- /dev/null +++ b/notebook-examples/sqlnotebook-docs/pages/concepts/Sql Blocks.md @@ -0,0 +1,9 @@ +# SQL Blocks + +SQL markdown code blocks are used to perform queries and display results. + +```` +```sql type="timeseries" server="localhost:5000" +([] dt:2013.01.01+til 21; cosineWave:cos a; sineWave:sin a:0.6*til 21) +``` +```` \ No newline at end of file diff --git a/notebook-examples/sqlnotebook-docs/pages/concepts/index.md b/notebook-examples/sqlnotebook-docs/pages/concepts/index.md new file mode 100644 index 0000000..a653814 --- /dev/null +++ b/notebook-examples/sqlnotebook-docs/pages/concepts/index.md @@ -0,0 +1,12 @@ +# Concepts + +SQL Notebooks are a single markdown text document with additional support for SQL and no-code components that allow data teams to quickly build beautiful reports. +Blocks + +Notebooks are made up of a series of blocks: + + - [SQL blocks](Sql%20Blocks) are used to write SQL queries against databases or other data sources. + - [Markdown blocks](Markdown%20Blocks) allow you to use markdown formatted text. + - [Chart blocks](Chart%20Blocks) Allow taking an SQL query and visualizing it as various charts and visualizations. + - [Input blocks](Input%20Blocks) are interactive widgets that capture user inputs, you can then use them as variables within SQL queries. + diff --git a/notebook-examples/sqlnotebook-docs/pages/index.md b/notebook-examples/sqlnotebook-docs/pages/index.md new file mode 100644 index 0000000..7fafb61 --- /dev/null +++ b/notebook-examples/sqlnotebook-docs/pages/index.md @@ -0,0 +1,20 @@ +# What is an SQLNotebook + +SQLNotebooks are a code-driven method for building data applications with SQL. +This includes reports, analysis, monitoring and embedded dashboards. + +SQLNotebooks allow someone that knows SQL and a little markdown to create beatiful fully interactive data applications. + +# What is qStudio / Pulse? + + - [qStudio](https://www.timestored.com/qstudio) is a Free SQL Client. + - [Pulse](https://www.timestored.com/pulse) is a self-hostable platform for creating dashboards or SQLNotebooks + - Both products are produced by [Pulse](https://www.timestored.com) a company that has been supplying data tools since 2013. + +# How does it work? + +1. A user creates a markdown document using SQLMarkdown syntax. +2. The engine allows a user to view the markdown as HTML in a browser. +3. The engine takes the SQL Queries defined in the markdown and runs them against its' Data Sources. +4. The results are rendered as Charts or other output components. +4. A user can provide input, for example by selecting options in dropdowns, these can change Variables in a query, which then refreshes the charts. diff --git a/notebook-examples/sqlnotebook-docs/pages/setup.md b/notebook-examples/sqlnotebook-docs/pages/setup.md new file mode 100644 index 0000000..a453fe0 --- /dev/null +++ b/notebook-examples/sqlnotebook-docs/pages/setup.md @@ -0,0 +1,16 @@ +Sql notebooks are available within both our free SQL client [qStudio](https://www.timestored.com/qstudio) and our self-hosted server web application [Pulse](https://www.timestored.com/pulse). + +Click below to [download](https://www.timestored.com/qstudio/download). + +### Single User - Desktop Editor + +[qstudio](https://www.timestored.com/qstudio/download) + +Works on Windows/Mac/Linux + + +#### Teams Edition - Hosted Web App + +[Pulse](https://www.timestored.com/pulse/download) + +Users access via their browser \ No newline at end of file diff --git a/notebook-examples/sqlnotebook-docs/pulse.png b/notebook-examples/sqlnotebook-docs/pulse.png new file mode 100644 index 0000000..b9da0ec Binary files /dev/null and b/notebook-examples/sqlnotebook-docs/pulse.png differ