AngularJS 1.5> $doCheck after stoped rendering
I'm trying to build a D3 chart inside a AngularJS component. I wan't to update when data changes ( by one way binding ) or when the chart is made bigger via a Button.
As far as I got is using $doCheck (because $onChange is not fired when data is updated or when parent resize happens ). The problem is that $doCheck is fired before the parent is finished rendering ( Container width is the old one ).
If you have any tips it would be great.
Thanks
Related
We are currently building a reactjs application. One of the component requires the use of react-google-chart to display an annotation chart.
Am able to get the chart displayed without issues - a requirement specifies that on the annotations table to the right we have a button for each row and clicking on that should trigger a event that could access a method on the parent component (i.e a parent component holding the Chart)
Here is a sandbox code for this
https://codesandbox.io/s/react-google-charts-annotation-chart-d4px2
Note the 'Click me' buttons on the annotation table next to the chart
Solutions Tried
Initially tried with 'select' event of the google annotation
chart(passing in chartEvents) but those events are fired on the chart
but would not be fired when clicked on the annotation table
Tried passing in a function as a property to the react-google-chart componet as shown but from button onClick there was no way i could refer this function via property like this.props.getDetail etc..
Ideally would like to see a solution where clicking the buttons on the annotation chart ....we are able to call a function on the parent component.
Currently cant access a function(#getDetail) in the parent component i.e App in the above example
I'm using Angular 2 - RC3.
My problem is, I have an item which is shown or hidden using a *ngIf.
When the item is getting shown or hidden I want to apply an animation.
I'am able to apply an animation when the item first shows simply by adding a class. But the problem is when it's getting removed, the item gets removed from the screen before the animation can start/finish.
I know you can overcome this by setting a timer to delay removing action so that the animation can finish. But I don't want to put timers everywhere I need this functionality.
Is there an easier way in Angular to achieve this?
I don't want to use JQuery is either.
Use [hidden] directive on your element, as it does not prevent the element from rendering like *ngIf does.
[hidden] mean it takes up space in your DOM document but it's display is set to : none !important.
*ngIf on the other hand removes the element from the DOM completly
This is essentially my HTML. It is part of a responsive design so I cannot rely on fixed widths/heights:
<img ng-src="{{imageSrc}}" />
The value of $scope.imageSrc is changed inside my controller and the view is updating properly.
But: At the point of time the image has finished rendering I need to get its clientWidth and clientHeight properties.
So how can I detect programmatically that
the image has finished loading and
the view has been fully updated with the rendered image
without using weird timeouts?
Two other questions will help you here.
This SO post will detect loading via the load event.
And this post will detect rendering via requestAnimationFrame.
Scenario:Update the angular kendo grid on click of various buttons.Able to update the grid with new service returned values.
Issue: Angular kendo grid flickers for a second while refreshing.
HTML Structure: Tried with & without k-ng-delay
<div id="alertGrid" kendo-grid k-options="alertGridOptions"
k-rebind="alertGridOptions" k-ng-delay="alertGridOptions.dataSource">
</div>
The function that is called on click of refresh buttons
$scope.renderAlertGrid=function(){
$scope.alertDataSource.read();
//$('#alertGrid').data('kendoGrid').refresh();
};
Tried to use only refresh, it dint worked out. No impact in using along with read() as well.
Everything is working fine,just that UI becomes little awkward during refresh due to that 1 sec flicker and refresh.
Kindly help out
Thanks
Your problem is that your data source is declared inside your options object and you're binding to your data by referencing your options object using k-options and then you are using k-rebind to watch for changes on your options object. So every time your data source changes in your options object the entire grid will re-render and all your scroll etc will reset because k-rebind re-renders every time a change in your options object is detected.
You need to remove k-rebind and bind to your data source separately using the k-data-source attribute. Then the rows in your grid will update when the data changes in your data source without re-rendering the entire grid.
k-rebind is used when the options object has to be changed and the entire widget re-rendered. For example switching a bar chart to a pie chart. That requires a full re-render. k-rebind is a bit of a hack and should be avoided imo.
There is a Marionette ItemView which is rendered correctly the first time as a bar at the left side of the window. The side bar can be hide and it happens correctly by calling the close method of the view. However, when I want to show the side bar again I create a new instance of the view and show it in the region it is not displayed. The initialize method is called as well as the onShow but the elements are not added to the DOM thus they are not shown in the screen. Thanks for your help in advance