diff --git a/docusaurus/docs/Chart from Table.mdx b/docusaurus/docs/Chart from Table.mdx index 80a5240..43cc9e3 100644 --- a/docusaurus/docs/Chart from Table.mdx +++ b/docusaurus/docs/Chart from Table.mdx @@ -34,7 +34,8 @@ beginAtZero: true ``` ```` -4. Choose the column or row oriented layout using the `layout` key. Options are `rows` or `columns`. +4. Choose the column or row oriented layout using the `layout` attribute. Options are `rows` or `columns`. +5. (Optional) Select the Columns or Rows with the `select` attribute. E.g. to only show Row `Data2` add `select: [Data2]` ## Replace Table with Chart diff --git a/manifest.json b/manifest.json index 1a9eb5d..44fc39a 100644 --- a/manifest.json +++ b/manifest.json @@ -1,7 +1,7 @@ { "id": "obsidian-charts", "name": "Obsidian Charts", - "version": "3.4.6", + "version": "3.4.7", "minAppVersion": "0.12.7", "description": "This Plugin lets you create Charts within Obsidian", "author": "phibr0", diff --git a/src/chartFromTable.ts b/src/chartFromTable.ts index e3ffa3f..e7d5671 100644 --- a/src/chartFromTable.ts +++ b/src/chartFromTable.ts @@ -18,7 +18,7 @@ beginAtZero: true editor.replaceSelection(chart); } -export function generateTableData(table: string, layout: 'columns' | 'rows') { +export function generateTableData(table: string, layout: 'columns' | 'rows', selected?: string[]) { let fields: any; try { fields = Extractor.extractObject(table, layout, false); @@ -33,5 +33,14 @@ export function generateTableData(table: string, layout: 'columns' | 'rows') { data: Object.values(fields[key]) as string[] } }); + + if(selected) { + dataFields.filter((v) => { + if(!selected.contains(v.dataTitle)) { + dataFields.remove(v) + } + }); + } + return {labels, dataFields}; } \ No newline at end of file diff --git a/src/chartRenderer.ts b/src/chartRenderer.ts index 215798d..e87a939 100644 --- a/src/chartRenderer.ts +++ b/src/chartRenderer.ts @@ -252,7 +252,7 @@ class ChartRenderChild extends MarkdownRenderChild { const tableString = (await this.renderer.plugin.app.vault.cachedRead(this.data.file ? linkDest : this.renderer.plugin.app.vault.getAbstractFileByPath(this.ownPath) as TFile)).substring(pos.start.offset, pos.end.offset); let tableData; try { - tableData = generateTableData(tableString, this.data.layout ?? 'columns'); + tableData = generateTableData(tableString, this.data.layout ?? 'columns', this.data.select); } catch (error) { throw "There is no table at that id and/or file" }