working code with dynamic chart load
This commit is contained in:
@@ -42,7 +42,8 @@
|
|||||||
</ul>
|
</ul>
|
||||||
</nav>
|
</nav>
|
||||||
<div style="width: 100%;">
|
<div style="width: 100%;">
|
||||||
<gridster [options]="options" (drop)="onDrop($event)" style="background-color: transparent;">
|
<!-- Remove the (drop) event binding since it's already handled by gridster's emptyCellDropCallback -->
|
||||||
|
<gridster [options]="options" style="background-color: transparent;">
|
||||||
<gridster-item [item]="item" *ngFor="let item of dashboardArray">
|
<gridster-item [item]="item" *ngFor="let item of dashboardArray">
|
||||||
<!-- <ng-container *ngIf="addToDashboard && item.addToDashboard"> -->
|
<!-- <ng-container *ngIf="addToDashboard && item.addToDashboard"> -->
|
||||||
<button class="btn btn-icon btn-danger" style="margin-left: 10px; margin-top: 10px;" (click)="removeItem(item)" *ngIf="!fromRunner">
|
<button class="btn btn-icon btn-danger" style="margin-left: 10px; margin-top: 10px;" (click)="removeItem(item)" *ngIf="!fromRunner">
|
||||||
|
|||||||
@@ -66,18 +66,18 @@ export class EditnewdashComponent implements OnInit {
|
|||||||
name: 'Common Filter',
|
name: 'Common Filter',
|
||||||
identifier: 'common_filter'
|
identifier: 'common_filter'
|
||||||
},
|
},
|
||||||
{
|
// {
|
||||||
name: 'Radar Chart',
|
// name: 'Radar Chart',
|
||||||
identifier: 'radar_chart'
|
// identifier: 'radar_chart'
|
||||||
},
|
// },
|
||||||
{
|
// {
|
||||||
name: 'Doughnut Chart',
|
// name: 'Doughnut Chart',
|
||||||
identifier: 'doughnut_chart'
|
// identifier: 'doughnut_chart'
|
||||||
},
|
// },
|
||||||
{
|
// {
|
||||||
name: 'Line Chart',
|
// name: 'Line Chart',
|
||||||
identifier: 'line_chart'
|
// identifier: 'line_chart'
|
||||||
},
|
// },
|
||||||
// {
|
// {
|
||||||
// name: 'Bar Chart',
|
// name: 'Bar Chart',
|
||||||
// identifier: 'bar_chart'
|
// identifier: 'bar_chart'
|
||||||
@@ -98,22 +98,22 @@ export class EditnewdashComponent implements OnInit {
|
|||||||
// name: 'Scatter Chart',
|
// name: 'Scatter Chart',
|
||||||
// identifier: 'scatter_chart'
|
// identifier: 'scatter_chart'
|
||||||
// },
|
// },
|
||||||
{
|
// {
|
||||||
name: 'Dynamic Chart',
|
// name: 'Dynamic Chart',
|
||||||
identifier: 'dynamic_chart'
|
// identifier: 'dynamic_chart'
|
||||||
},
|
// },
|
||||||
{
|
// {
|
||||||
name: 'Financial Chart',
|
// name: 'Financial Chart',
|
||||||
identifier: 'financial_chart'
|
// identifier: 'financial_chart'
|
||||||
},
|
// },
|
||||||
{
|
// {
|
||||||
name: 'To Do',
|
// name: 'To Do',
|
||||||
identifier: 'to_do_chart'
|
// identifier: 'to_do_chart'
|
||||||
},
|
// },
|
||||||
{
|
// {
|
||||||
name: 'Grid View',
|
// name: 'Grid View',
|
||||||
identifier: 'grid_view'
|
// identifier: 'grid_view'
|
||||||
},
|
// },
|
||||||
{
|
{
|
||||||
name: 'Compact Filter',
|
name: 'Compact Filter',
|
||||||
identifier: 'compact_filter'
|
identifier: 'compact_filter'
|
||||||
@@ -2110,6 +2110,9 @@ export class EditnewdashComponent implements OnInit {
|
|||||||
|
|
||||||
this.dashboardArray.push(chartItem);
|
this.dashboardArray.push(chartItem);
|
||||||
console.log(`Created dynamic chart:`, chartItem);
|
console.log(`Created dynamic chart:`, chartItem);
|
||||||
|
|
||||||
|
// Update the dashboard collection and trigger refresh
|
||||||
|
this.itemChange();
|
||||||
},
|
},
|
||||||
error: (error) => {
|
error: (error) => {
|
||||||
console.error(`Error loading configuration for ${chartTypeName}:`, error);
|
console.error(`Error loading configuration for ${chartTypeName}:`, error);
|
||||||
@@ -2180,13 +2183,8 @@ export class EditnewdashComponent implements OnInit {
|
|||||||
this.dashboardArray.push(chartItem);
|
this.dashboardArray.push(chartItem);
|
||||||
console.log('Created default chart:', chartItem);
|
console.log('Created default chart:', chartItem);
|
||||||
|
|
||||||
// Update the dashboard collection
|
// Update the dashboard collection and trigger refresh
|
||||||
this.dashboardCollection.dashboard = this.dashboardArray.slice();
|
this.itemChange();
|
||||||
|
|
||||||
// Force gridster to refresh
|
|
||||||
if (this.options && this.options.api) {
|
|
||||||
this.options.api.optionsChanged();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Helper method to get display name for chart type - making it fully dynamic
|
// Helper method to get display name for chart type - making it fully dynamic
|
||||||
|
|||||||
@@ -33,7 +33,7 @@
|
|||||||
[labels]="chartLabels"
|
[labels]="chartLabels"
|
||||||
[options]="chartOptions"
|
[options]="chartOptions"
|
||||||
[legend]="chartLegend"
|
[legend]="chartLegend"
|
||||||
[chartType]="chartType || 'bar'"
|
[type]="chartType || 'bar'"
|
||||||
(chartClick)="chartClicked($event)"
|
(chartClick)="chartClicked($event)"
|
||||||
(chartHover)="chartHovered($event)">
|
(chartHover)="chartHovered($event)">
|
||||||
</canvas>
|
</canvas>
|
||||||
@@ -46,7 +46,7 @@
|
|||||||
[labels]="chartLabels"
|
[labels]="chartLabels"
|
||||||
[options]="chartOptions"
|
[options]="chartOptions"
|
||||||
[legend]="chartLegend"
|
[legend]="chartLegend"
|
||||||
[chartType]="'bar'"
|
[type]="'bar'"
|
||||||
(chartClick)="chartClicked($event)"
|
(chartClick)="chartClicked($event)"
|
||||||
(chartHover)="chartHovered($event)">
|
(chartHover)="chartHovered($event)">
|
||||||
</canvas>
|
</canvas>
|
||||||
|
|||||||
@@ -682,30 +682,30 @@ export class UnifiedChartComponent implements OnInit, OnChanges, OnDestroy {
|
|||||||
}
|
}
|
||||||
|
|
||||||
switch (this.chartType) {
|
switch (this.chartType) {
|
||||||
case 'bar':
|
// case 'bar':
|
||||||
this.initializeBarChartOptions();
|
// this.initializeBarChartOptions();
|
||||||
break;
|
// break;
|
||||||
case 'line':
|
// case 'line':
|
||||||
this.initializeLineChartOptions();
|
// this.initializeLineChartOptions();
|
||||||
break;
|
// break;
|
||||||
case 'pie':
|
// case 'pie':
|
||||||
this.initializePieChartOptions();
|
// this.initializePieChartOptions();
|
||||||
break;
|
// break;
|
||||||
case 'doughnut':
|
// case 'doughnut':
|
||||||
this.initializeDoughnutChartOptions();
|
// this.initializeDoughnutChartOptions();
|
||||||
break;
|
// break;
|
||||||
case 'bubble':
|
// case 'bubble':
|
||||||
this.initializeBubbleChartOptions();
|
// this.initializeBubbleChartOptions();
|
||||||
break;
|
// break;
|
||||||
case 'radar':
|
// case 'radar':
|
||||||
this.initializeRadarChartOptions();
|
// this.initializeRadarChartOptions();
|
||||||
break;
|
// break;
|
||||||
case 'polar':
|
// case 'polar':
|
||||||
this.initializePolarChartOptions();
|
// this.initializePolarChartOptions();
|
||||||
break;
|
// break;
|
||||||
case 'scatter':
|
// case 'scatter':
|
||||||
this.initializeScatterChartOptions();
|
// this.initializeScatterChartOptions();
|
||||||
break;
|
// break;
|
||||||
default:
|
default:
|
||||||
this.initializeDefaultChartOptions();
|
this.initializeDefaultChartOptions();
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user