jaumard / ngx-dashboard

Dashboard library for angular 4 and more
https://jaumard.github.io/ngx-dashboard/demo/demoDist/index.html
MIT License
71 stars 31 forks source link

Resizable widgets #34

Open anvial opened 7 years ago

anvial commented 7 years ago

Hello again,

I would like to implement resizable widgets. How can I include onResize event in WidgetComponent in manner of цшвпуе "onClose" event

Just adding a new event emitter is not enought:

  @Output() onClose = new EventEmitter<any>();
  @Output() onResize = new EventEmitter<any>();

It causing a error that: image during adding widget to dashboard:

this.ref[wId] = this.dashboard.addItem(component);
          this.ref[wId].widgetId = wId;
          this.ref[wId].setSize([wData.sizeX, wData.sizeY]);
          this.ref[wId].ngOnInit();
          this.ref[wId].onClose.subscribe(id => {
            this.dashboard.removeItemById(id);
            for (let w of this.dashboardWidgetDataList) {
              if (w.name === wData.name) {
                let index = this.dashboardWidgetDataList.indexOf(w, 0);
                if (index > -1) {
                  this.dashboardWidgetDataList.splice(index, 1);
                }
              }
            }
          });
// HERE IS A ERROR --->
          this.ref[wId].onResize.subscribe(data => {
            this.ref[data.id].setSize([data.newSize.x, data.newSize.y]);
          });

Any suggestions?

anvial commented 7 years ago

In widgetComponent source I found

    onSizeChanged: EventEmitter<number[]>;

I think this is the solution. But another question: How to update (redraw) widget after resizing?

jaumard commented 6 years ago

Hello,

Normally they should be redrawn automatically when you update the size, it's not the case ? You can also try to refresh them manually by calling refreshWidgets() on the dashboard component