diff --git a/frontend/angular-clarity-master/src/app/modules/main/builder/dashboardnew/editnewdash/editnewdash.component.ts b/frontend/angular-clarity-master/src/app/modules/main/builder/dashboardnew/editnewdash/editnewdash.component.ts index 4c0cc40..401e392 100644 --- a/frontend/angular-clarity-master/src/app/modules/main/builder/dashboardnew/editnewdash/editnewdash.component.ts +++ b/frontend/angular-clarity-master/src/app/modules/main/builder/dashboardnew/editnewdash/editnewdash.component.ts @@ -131,16 +131,16 @@ export class EditnewdashComponent implements OnInit { protected componentCollection = [ { name: "Common Filter", componentInstance: CommonFilterComponent }, - { name: "Line Chart", componentInstance: LineChartComponent }, - { name: "Doughnut Chart", componentInstance: DoughnutChartComponent }, - { name: "Radar Chart", componentInstance: RadarChartComponent }, - { name: "Bar Chart", componentInstance: BarChartComponent }, - { name: "Pie Chart", componentInstance: PieChartComponent }, - { name: "Polar Area Chart", componentInstance: PolarChartComponent }, - { name: "Bubble Chart", componentInstance: BubbleChartComponent }, - { name: "Scatter Chart", componentInstance: ScatterChartComponent }, - { name: "Dynamic Chart", componentInstance: DynamicChartComponent }, - { name: "Financial Chart", componentInstance: FinancialChartComponent }, + { name: "Line Chart", componentInstance: UnifiedChartComponent }, + { name: "Doughnut Chart", componentInstance: UnifiedChartComponent }, + { name: "Radar Chart", componentInstance: UnifiedChartComponent }, + { name: "Bar Chart", componentInstance: UnifiedChartComponent }, + { name: "Pie Chart", componentInstance: UnifiedChartComponent }, + { name: "Polar Area Chart", componentInstance: UnifiedChartComponent }, + { name: "Bubble Chart", componentInstance: UnifiedChartComponent }, + { name: "Scatter Chart", componentInstance: UnifiedChartComponent }, + { name: "Dynamic Chart", componentInstance: UnifiedChartComponent }, + { name: "Financial Chart", componentInstance: UnifiedChartComponent }, { name: "To Do Chart", componentInstance: ToDoChartComponent }, { name: "Grid View", componentInstance: GridViewComponent }, { name: "Compact Filter", componentInstance: CompactFilterComponent }, @@ -393,6 +393,27 @@ export class EditnewdashComponent implements OnInit { } }); + // Map chart names to unified chart types + const chartTypeMap = { + 'Radar Chart': 'radar', + 'Line Chart': 'line', + 'Doughnut Chart': 'doughnut', + 'Bar Chart': 'bar', + 'Pie Chart': 'pie', + 'Polar Area Chart': 'polar', + 'Bubble Chart': 'bubble', + 'Scatter Chart': 'scatter', + 'Dynamic Chart': 'line', + 'Financial Chart': 'line' + }; + + // If this is a chart, set the chartType property + if (chartTypeMap.hasOwnProperty(dashboard.name)) { + dashboard.chartType = chartTypeMap[dashboard.name]; + // Change the name to "Unified Chart" for consistency + dashboard.name = "Unified Chart"; + } + // Ensure compact filter configuration properties are properly initialized if (dashboard.component === 'Compact Filter' || dashboard.name === 'Compact Filter') { // Make sure all compact filter properties exist @@ -417,6 +438,23 @@ export class EditnewdashComponent implements OnInit { } }); + // Map unified chart types back to chart names for serialization + const chartNameMap = { + 'radar': 'Radar Chart', + 'line': 'Line Chart', + 'doughnut': 'Doughnut Chart', + 'bar': 'Bar Chart', + 'pie': 'Pie Chart', + 'polar': 'Polar Area Chart', + 'bubble': 'Bubble Chart', + 'scatter': 'Scatter Chart' + }; + + // If this is a unified chart, set the name back to the appropriate chart name + if (dashboard.name === 'Unified Chart' && dashboard.chartType && chartNameMap.hasOwnProperty(dashboard.chartType)) { + dashboard.name = chartNameMap[dashboard.chartType]; + } + // Ensure compact filter configuration properties are preserved if (dashboard.name === 'Compact Filter') { // Make sure all compact filter properties exist @@ -428,6 +466,7 @@ export class EditnewdashComponent implements OnInit { } }); } + // Add method to get available fields for a filter dropdown (excluding already selected fields) getAvailableFields(filters: any[], currentIndex: number, allFields: string[]): string[] { if (!filters || !allFields) { @@ -473,6 +512,7 @@ export class EditnewdashComponent implements OnInit { } } switch (componentType) { + // Handle all chart types by converting them to unified charts case "radar_chart": return this.dashboardArray.push({ cols: 5, @@ -480,8 +520,13 @@ export class EditnewdashComponent implements OnInit { x: 0, y: 0, chartid: maxChartId + 1, - component: RadarChartComponent, - name: "Radar Chart" + component: UnifiedChartComponent, + name: "Unified Chart", + chartType: 'radar', + xAxis: '', + yAxis: '', + table: '', + connection: undefined }); case "line_chart": return this.dashboardArray.push({ @@ -490,8 +535,13 @@ export class EditnewdashComponent implements OnInit { x: 0, y: 0, chartid: maxChartId + 1, - component: LineChartComponent, - name: "Line Chart" + component: UnifiedChartComponent, + name: "Unified Chart", + chartType: 'line', + xAxis: '', + yAxis: '', + table: '', + connection: undefined }); case "doughnut_chart": return this.dashboardArray.push({ @@ -500,8 +550,13 @@ export class EditnewdashComponent implements OnInit { x: 0, y: 0, chartid: maxChartId + 1, - component: DoughnutChartComponent, - name: "Doughnut Chart" + component: UnifiedChartComponent, + name: "Unified Chart", + chartType: 'doughnut', + xAxis: '', + yAxis: '', + table: '', + connection: undefined }); case "bar_chart": return this.dashboardArray.push({ @@ -510,8 +565,13 @@ export class EditnewdashComponent implements OnInit { x: 0, y: 0, chartid: maxChartId + 1, - component: BarChartComponent, - name: "Bar Chart" + component: UnifiedChartComponent, + name: "Unified Chart", + chartType: 'bar', + xAxis: '', + yAxis: '', + table: '', + connection: undefined }); case "pie_chart": return this.dashboardArray.push({ @@ -520,8 +580,13 @@ export class EditnewdashComponent implements OnInit { x: 0, y: 0, chartid: maxChartId + 1, - component: PieChartComponent, - name: "Pie Chart" + component: UnifiedChartComponent, + name: "Unified Chart", + chartType: 'pie', + xAxis: '', + yAxis: '', + table: '', + connection: undefined }); case "polar_area_chart": return this.dashboardArray.push({ @@ -530,8 +595,13 @@ export class EditnewdashComponent implements OnInit { x: 0, y: 0, chartid: maxChartId + 1, - component: PolarChartComponent, - name: "Polar Area Chart" + component: UnifiedChartComponent, + name: "Unified Chart", + chartType: 'polar', + xAxis: '', + yAxis: '', + table: '', + connection: undefined }); case "bubble_chart": return this.dashboardArray.push({ @@ -540,8 +610,13 @@ export class EditnewdashComponent implements OnInit { x: 0, y: 0, chartid: maxChartId + 1, - component: BubbleChartComponent, - name: "Bubble Chart" + component: UnifiedChartComponent, + name: "Unified Chart", + chartType: 'bubble', + xAxis: '', + yAxis: '', + table: '', + connection: undefined }); case "scatter_chart": return this.dashboardArray.push({ @@ -550,8 +625,13 @@ export class EditnewdashComponent implements OnInit { x: 0, y: 0, chartid: maxChartId + 1, - component: ScatterChartComponent, - name: "Scatter Chart" + component: UnifiedChartComponent, + name: "Unified Chart", + chartType: 'scatter', + xAxis: '', + yAxis: '', + table: '', + connection: undefined }); case "dynamic_chart": return this.dashboardArray.push({ @@ -560,8 +640,13 @@ export class EditnewdashComponent implements OnInit { x: 0, y: 0, chartid: maxChartId + 1, - component: DynamicChartComponent, - name: "Dynamic Chart" + component: UnifiedChartComponent, + name: "Unified Chart", + chartType: 'line', // Default to line for dynamic chart + xAxis: '', + yAxis: '', + table: '', + connection: undefined }); case "financial_chart": return this.dashboardArray.push({ @@ -570,8 +655,13 @@ export class EditnewdashComponent implements OnInit { x: 0, y: 0, chartid: maxChartId + 1, - component: FinancialChartComponent, - name: "Financial Chart" + component: UnifiedChartComponent, + name: "Unified Chart", + chartType: 'line', // Default to line for financial chart + xAxis: '', + yAxis: '', + table: '', + connection: undefined }); case "to_do_chart": return this.dashboardArray.push({