### Create Markdown Table Source: https://github.com/h-sphere/sql-seal-charts/blob/main/docs/quick-start.md This markdown code defines a simple table with 'Category' and 'Amount' columns, used as a data source for SQLSeal Charts. ```markdown | Category | Amount | | ------------- | | Grocery | 200 | | Rent | 1500 | | Entertainment | 130 | | Bills | 400 | ``` -------------------------------- ### SQLSeal: Pie Chart Source: https://github.com/h-sphere/sql-seal-charts/blob/main/README.md Example SQLSeal query to generate a pie chart from tabular data. It defines the data source and specifies the chart type as 'pie'. ```sqlseal TABLE finances = table(0) CHART { series: [{ type: 'pie' }] } SELECT * FROM finances ``` -------------------------------- ### SQLSeal Chart Code Source: https://github.com/h-sphere/sql-seal-charts/blob/main/docs/quick-start.md This SQLSeal code block defines a data source from a markdown table and configures a pie chart to visualize the data. It includes table definition, chart configuration, and an SQL SELECT statement. ```sqlseal TABLE data = table(0) CHART { series: [{ type: 'pie' }] } SELECT * FROM data ``` -------------------------------- ### SQLSeal: Line/Bar Chart Source: https://github.com/h-sphere/sql-seal-charts/blob/main/README.md Example SQLSeal query to generate a bar chart (can be adapted for line charts) using data grouped by date. It configures the axes and series type. ```sqlseal CHART { axisX: { type: 'category' }, axisY: {}, series: [{ type: 'bar', }] } SELECT strftime("%Y-%m-%d", created_at) as created_date, COUNT(*) as count FROM files GROUP BY created_date ORDER BY created_date ``` -------------------------------- ### Assembling objects using a key-value map with `assemble` in SQLSeal Charts Source: https://github.com/h-sphere/sql-seal-charts/blob/main/docs/syntax.md Shows the usage of the `assemble` function in SQLSeal Charts to create an array of objects from multiple arrays, utilizing a key-to-value map. This provides a concise way to structure data for visualization. ```javascript assemble({ category: column('category'), amount: column('amount') }) ``` -------------------------------- ### Assembling objects from arrays with `assembleObjects` in SQLSeal Charts Source: https://github.com/h-sphere/sql-seal-charts/blob/main/docs/syntax.md Demonstrates how to use the `assembleObjects` function to combine multiple arrays into an array of objects using provided key definitions in SQLSeal Charts. This is useful for structuring data for complex chart series. ```javascript assembleObjects({ key: 'category', values: column('category') }, { key: 'amount', values: column('amount') }) ``` -------------------------------- ### Using template literals with column data in SQLSeal Charts Source: https://github.com/h-sphere/sql-seal-charts/blob/main/docs/syntax.md Shows how to use JavaScript template literals to dynamically access and format data from a column in SQLSeal Charts. This allows for flexible data presentation in chart configurations. ```javascript `\${column('data')[0]}\` ``` -------------------------------- ### SQLSeal Advanced Mode JavaScript Chart Configuration Source: https://github.com/h-sphere/sql-seal-charts/blob/main/docs/advanced-mode.md Demonstrates using JavaScript within SQLSeal's Advanced Mode to transform data and define a bar chart's configuration. It accesses query results and helper functions to build the chart object, including tooltips, legend, axes, and series data. ```sqlseal ADVANCED MODE -- now you can use all JavaScript syntax to your heart content CHART const values = (new Array(5)).map((_, i) => i) return { tooltip: {}, legend: { data: ['sales'] }, xAxis: { data: ['Shirts', 'Cardigans', 'Chiffons', 'Pants', 'Heels', 'Socks'] }, yAxis: {}, series: [ { name: 'sales', type: 'bar', data: [5, 20, 36, 10, 10, 20] } ] } SELECT * FROM files ``` -------------------------------- ### SQLSeal Clustering with ECharts Scatter Plot Source: https://github.com/h-sphere/sql-seal-charts/blob/main/docs/data-analysis-features.md Demonstrates how to perform K-Means clustering on CSV data using SQLSeal and visualize the results as a scatter plot with ECharts. It includes data loading, clustering configuration, and chart rendering. ```sqlseal TABLE clustering = file(./Clustering Data.csv) ADVANCED MODE CHART const datasetArray = data.map(d => ([d.x, d.y])) var CLUSTER_COUNT = 6; var DIENSIION_CLUSTER_INDEX = 2; var COLOR_ALL = [ '#37A2DA', '#e06343', '#37a354', '#b55dba', '#b5bd48', '#8378EA', '#96BFFF' ]; var pieces = []; for (var i = 0; i < CLUSTER_COUNT; i++) { pieces.push({ value: i, label: 'cluster ' + i, color: COLOR_ALL[i] }); } return { dataset: [ { source: datasetArray }, { transform: { type: 'ecStat:clustering', print: true, config: { clusterCount: CLUSTER_COUNT, outputType: 'single', outputClusterIndexDimension: DIENSIION_CLUSTER_INDEX } } } ], tooltip: { position: 'top' }, visualMap: { type: 'piecewise', top: 'middle', min: 0, max: CLUSTER_COUNT, left: 10, splitNumber: CLUSTER_COUNT, dimension: DIENSIION_CLUSTER_INDEX, pieces: pieces }, grid: { left: 120 }, xAxis: {}, yAxis: {}, series: { type: 'scatter', encode: { tooltip: [0, 1] }, symbolSize: 15, itemStyle: { borderColor: '#555' }, datasetIndex: 1 } }; SELECT * FROM clustering ``` -------------------------------- ### Accessing column data with JavaScript in SQLSeal Charts Source: https://github.com/h-sphere/sql-seal-charts/blob/main/docs/syntax.md Demonstrates how to use the `column` function to retrieve data for a specific column within SQLSeal Charts. This is useful for accessing and manipulating data series for charting. ```javascript column('data') ``` -------------------------------- ### SQLSeal Regression Chart Source: https://github.com/h-sphere/sql-seal-charts/blob/main/docs/data-analysis-features.md Generates a scatter plot with an exponential regression line using SQLSeal and ECharts. It reads data from a CSV file, transforms it for regression, and configures chart elements like titles, tooltips, and axes. ```sqlseal TABLE regression = file(./Regression Data.csv) ADVANCED MODE CHART const dataArray = data.map(d => ([d.x, d.y])) return { dataset: [ { source: dataArray }, { transform: { type: 'ecStat:regression', config: { method: 'exponential' // 'end' by default // formulaOn: 'start' } } } ], title: { text: '1981 - 1998 gross domestic product GDP (trillion yuan)', subtext: 'By ecStat.regression', sublink: 'https://github.com/ecomfe/echarts-stat', left: 'center' }, tooltip: { trigger: 'axis', axisPointer: { type: 'cross' } }, xAxis: { splitLine: { lineStyle: { type: 'dashed' } } }, yAxis: { splitLine: { lineStyle: { type: 'dashed' } } }, series: [ { name: 'scatter', type: 'scatter', datasetIndex: 0 }, { name: 'line', type: 'line', smooth: true, datasetIndex: 1, symbolSize: 0.1, symbol: 'circle', label: { show: true, fontSize: 16 }, labelLayout: { dx: -20 }, encode: { label: 2, tooltip: 1 } } ] } SELECT * FROM regression ``` -------------------------------- ### Creating subarrays with the `array` function in SQLSeal Charts Source: https://github.com/h-sphere/sql-seal-charts/blob/main/docs/syntax.md Illustrates the use of the `array` function in SQLSeal Charts to create subarrays from multiple arrays. This is helpful for reshaping data, such as when grouping columns for different series. ```javascript array([1,2], [3,4 ]) == [[1,3], [2,4]] ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.