From d8adc003ae9350a1a76cd5a43c266023018a41e3 Mon Sep 17 00:00:00 2001 From: Peter Paul Kirschner Date: Thu, 30 Jul 2020 14:12:53 +0200 Subject: [PATCH] legend options --- .../modernCharts/ModernChartsWebPart.ts | 44 +++++++++---------- .../modernCharts/components/ModernCharts.tsx | 10 ++--- 2 files changed, 27 insertions(+), 27 deletions(-) diff --git a/samples/react-modern-charts/src/webparts/modernCharts/ModernChartsWebPart.ts b/samples/react-modern-charts/src/webparts/modernCharts/ModernChartsWebPart.ts index bccdfcfa0..bf92524ce 100644 --- a/samples/react-modern-charts/src/webparts/modernCharts/ModernChartsWebPart.ts +++ b/samples/react-modern-charts/src/webparts/modernCharts/ModernChartsWebPart.ts @@ -31,7 +31,7 @@ export interface ISPList { Id: string; } -export interface IFieldProperty extends IPropertyPaneDropdownOption{ +export interface IFieldProperty extends IPropertyPaneDropdownOption { fieldtype: string; } @@ -211,18 +211,18 @@ export default class ModernChartsWebPart extends BaseClientSideWebPart 0) { + private getLabel(item: Object, col: string) { + if (!!item[col] && !!item[col]['WssId'] && !!item["TaxCatchAll"] && item["TaxCatchAll"].length > 0) { //Filter because you can have more Fields from this type to select the right value - const wssid:number = item[col]['WssId']; - const terms = (item["TaxCatchAll"]).filter((x) => x.ID === wssid ); - if(!!terms && terms.length >0) { + const wssid: number = item[col]['WssId']; + const terms = (item["TaxCatchAll"]).filter((x) => x.ID === wssid); + if (!!terms && terms.length > 0) { return terms[0].Term; } return 'TermLabel not Found'; @@ -292,20 +292,20 @@ export default class ModernChartsWebPart extends BaseClientSideWebPart 0 - ) { - const selects=this.properties.chartConfig[pPathInd].columns.filter(f=> f.key === newValue); - if(selects.length >0) { -const selected=selects[0]; + if (pPath === 'col1' && (newValue != oldValue)) { + this.properties.chartConfig[pPathInd].hasTaxField = false; + if (!!newValue + && !!this.properties.chartConfig[pPathInd].columns + && this.properties.chartConfig[pPathInd].columns.length > 0 + ) { + const selects = this.properties.chartConfig[pPathInd].columns.filter(f => f.key === newValue); + if (selects.length > 0) { + const selected = selects[0]; - this.properties.chartConfig[pPathInd].hasTaxField = selected.fieldtype ==='TaxonomyFieldType'; + this.properties.chartConfig[pPathInd].hasTaxField = selected.fieldtype === 'TaxonomyFieldType'; + } + } } - }} //col1 this.context.propertyPane.refresh(); this.render(); @@ -498,10 +498,10 @@ const selected=selects[0]; const resturl = `/_api/web/lists/GetByTitle(\'${chartConfig['list']}\')/items?$orderby=Id desc&$limit=10&$top=${this.properties.maxResults}`; let requesturl = chartConfig['dataurl'] + resturl; - if(!!chartConfig['hasTaxField']) { + if (!!chartConfig['hasTaxField']) { requesturl = requesturl + urlparttax; } - return this.context.spHttpClient.get( requesturl, SPHttpClient.configurations.v1) + return this.context.spHttpClient.get(requesturl, SPHttpClient.configurations.v1) .then((response: SPHttpClientResponse) => { return response.json(); }); @@ -529,7 +529,7 @@ const selected=selects[0]; for (var _key in response.value) { respLists.push({ key: response.value[_key]['InternalName'], - text: response.value[_key]['Title'] , + text: response.value[_key]['Title'], fieldtype: response.value[_key]['TypeAsString'] }); } diff --git a/samples/react-modern-charts/src/webparts/modernCharts/components/ModernCharts.tsx b/samples/react-modern-charts/src/webparts/modernCharts/components/ModernCharts.tsx index 9a18f2d3f..ca7aece32 100644 --- a/samples/react-modern-charts/src/webparts/modernCharts/components/ModernCharts.tsx +++ b/samples/react-modern-charts/src/webparts/modernCharts/components/ModernCharts.tsx @@ -52,19 +52,19 @@ export default class ModernCharts extends React.Component; return tChart; case 'line': - tChart = ; - return tChart; + debugger; + return ; case 'pie': tChart = ; return tChart; case 'bar': - tChart = ; + tChart = ; return tChart; case 'horizontalbar': - tChart = ; + tChart = ; return tChart; case 'radar': - tChart = ; + tChart = ; return tChart; case 'polar': tChart = ;