How to destroy Charts in chartJS - angularjs

I have an angular + Ionic app in which I am using chartJS to show some data. Now charts are implemented on a slider.
Link1 Link2 and there are similar linked issues.
The solution that I came across. from many of the post is that I would have to destroy the existing chart and recreate in my window. Because whenever I change options via a drop drow the view blows up, all slides instead of coming next to each other laterally, Start showing up vertically and when I change the device mode. It actually re renders the page and I can view it normally.
I have tried it using ng-if also but it doesn't work. So how do I destroy a chart in my angular App and then recreate it
Some HTML code as to how am I doing it.
<div ng-if="metricArray">
<ion-slide-box on-slide-changed="slideHasChanged($index)" style="height:50%">
<ion-slide ng-repeat="metric in metricArray">
<div style="text-align:center; margin-top:10px; color:#eee;">
{{metric.startDate}} {{metric.endDate}}
</div>
<canvas id="myCanvas" tc-chartjs-bar chart-options="options" chart-data="metric.data" auto-legend></canvas>
<div class="row" style="margin-top:30px;">
<div style="width:33%; text-align:center">
<h6 style="color:#eee">MAX</h6>
<div class="circleBase type1 " style="padding:15px; margin-left: auto; margin-right: auto;">
<h6 style="color:#eee">{{metric.max}}</h6>
<p style="color:#eee">{{metricUnit}}</p>
</div>
</div>
<div style="width:33%; text-align:center">
<h6 style="color:#eee">MIN</h6>
<div class="circleBase type1 " style="padding:15px; margin-left: auto; margin-right: auto;">
<h6 style="color:#eee">{{metric.min}}</h6>
<p style="color:#eee">{{metricUnit}}</p>
</div>
</div>
<div style="width:33%; text-align:center">
<h6 style="color:#eee">AVG</h6>
<div class="circleBase type1 " style="padding:15px; margin-left: auto; margin-right: auto;">
<h6 style="color:#eee">{{metric.avg}}</h6>
<p style="color:#eee">{{metricUnit}}</p>
</div>
</div>
</div>
</ion-slide>
</ion-slide-box>
</div>

Related

AngularJS Transition on click

I am kind of new with angular and I found this way to use ng-click and ng-show to show the div with information in when the user clicks the h3.
The only problem is that it just shows up and I would like is it fades in or slides down to be visible. :)
Is this gonna work or should I do another way??
<div class="col-sm-12">
<div>
<h3 class="no-margin-bottom toggleText" ng-click="showInfoHe = !showInfoHe"><i class="fa fa-plus-circle" aria-hidden="true"></i> Hälsoinformation</h3>
<hr class="no-margin-top hr-line">
</div>
</div>
<div class="col-xs-12 col-md-offset-3 col-md-9 margin-top" style="border: 1px solid purple" ng-show="showInfoHe">
<div class="row cats-attributes">
<p>info</p>
</div>
</div>
You can do this without ngAnimate,
by using css transitions and ngClass
what you want to do on click set a variable to true and then have a class that has opacity:1.
so
<div class="parent-div" ng-click="yourVariable = true">
<div class="child" ng-class={'opacity-class': yourVariable}>
</div>
</div>
and then in the css
.parent-div {
transition: opacity ease-in-out 1s;
}
.parent-div.child {
opacity:0;
}
.opacity-class {
opacity: 1;
}
EDIT:
here is an applied solution to the html structure you provided
<div class="col-sm-12">
<div>
<h3 class="no-margin-bottom toggleText" ng-click="showInfoHe = !showInfoHe"><i class="fa fa-plus-circle" aria-hidden="true"></i> Hälsoinformation</h3>
<hr class="no-margin-top hr-line">
</div>
</div>
<div class="show-info-container">
<div class="col-xs-12 col-md-offset-3 col-md-9 margin-top show-info" style="border: 1px solid purple" ng-class="{'opacity-class':showInfoHe}">
<div class="row cats-attributes">
<p>info</p>
</div>
</div>
</div>
css
.show-info-container {
transition: opacity ease-in-out 1s;
}
.show-info {
opacity:0;
}
.opacity-class {
opacity: 1;
}
notice i added a container div and removed the ng-show

Prevent collapse of flexbox div in Angular Material

I'm developing a AngularJS (v1.5) application using Angular Material and I'm stuck with the implementation of the layout. This is basically a fixed-height header, followed by variable-height content, followed by a fixed-height footer. The complete page should scroll (including the header) and the footer should be pushed to the bottom of the window when there is not enough content to fill the space between header and footer.
I've created a pen with the code I've got so far (replaced components with div's and introduced all the intermediate div's inserted by Angular) but when I decrease the height of the window, the content is collapsed to a height of zero instead of maintaining the height of the content and showing a scrollbar.
The problem is probably with the .main CSS class but I cannot figure out what I should be putting there.
The HTML:
<body ng-app="app">
<!-- ui-view div -->
<div layout="column" layout-fill>
<!-- component div -->
<div layout-fill>
<!-- my own div around the page content -->
<div layout="column" layout-fill>
<!-- header component div -->
<div flex="none">
<header flex="none">
<md-toolbar>
<div class="container">
<div class="md-toolbar-tools" layout="row" layout-align="center center">
<div flex></div>
<h1>HEADER</h1>
<div flex></div>
</div>
</div>
</md-toolbar>
</header>
</div>
<!-- content div -->
<div flex class="container main">
<h2>CONTENT</h2>
</div>
<!-- footer component div -->
<div flex="none">
<footer flex="none">
<md-toolbar>
<div class="container">
<div class="md-toolbar-tools" layout="row" layout-align="center center">
<div flex></div>
<h1>FOOTER</h1>
<div flex></div>
</div>
</div>
</md-toolbar>
</footer>
</div>
</div>
</div>
</div>
</body>
The CSS:
header, footer {
md-toolbar {
height: 100px;
min-height: 100px;
background-color: #C8C8C8;
.md-toolbar-tools {
height: 100px;
min-height: 100px;
}
}
}
.container {
width: 600px;
margin: 0 auto;
}
.main {
background-color: #E8E8E8;
}
And the JavaScript:
angular.module("app", ['ngMaterial']);
The pen: http://codepen.io/kdbruin/pen/ZLwmvW
You can use flex="grow" with min-height on container to achieve the desired result.
Here is the Code
<div layout="column" flex="grow" style='background-color:green'>
<md-toolbar>
<div flex="10">
<div class="md-toolbar-tools" layout="row" layout-align="center center">
<div flex></div>
<h1>HEADER</h1>
<div flex></div>
</div>
</div>
</md-toolbar>
<div flex="grow" style='background-color:pink; min-height:1000px'>
<div ng-repeat="no in [0,1,2,3,4,5,6,7,8,9]">
<h2>CONTENT - {{no}}</h2>
</div>
</div>
<div flex="10" style='background-color:blue'>
<div flex></div>
<h1>FOOTER</h1>
<div flex></div>
</div>
Here is the working Codepen.

connect accordian heading and body through href and id

I have created a bootstrap accordian. When i click an accordian heading, it should show the body contents. I am providing the values dynamically(scope variable) for href and id attributes using angularjs.
But this is not working??
<div class="panel-group col-lg-3" style="background-color:#505054;height:450px" id="accordion">
<div class="panel" style="background-color:#505054;color:#C1C1C1;border-bottom: 1px solid #eee;">
<h6>Clear Filter</h6>
</div>
<div class="panel" style="background-color:#505054;color:white;border-bottom: 1px solid white;" ng-repeat="prdlines in detpline">
<div class="panel-heading">
<h6>
<div class="accordion-toggle" style="cursor:pointer" data-toggle="collapse" data-parent="#accordion" ng-click="plfilter(prdlines.id)" ng-href="{{prdlines.productline_name}}">{{prdlines.productline_name}}</div>
</h6>
</div>
<div ng-attr-id="{{prdlines.productline_name}}" class="panel-collapse collapse">
<div class="panel-body">
<ul id="style-3" style="height:200px; overflow: auto;cursor:pointer">
<li class="panel-title" ng-repeat="prd in detprd"><a ng-click="cfilter(prd.product_name)"><h5>{{prd.product_name}}</h5></a></li>
</ul>
</div>
</div>
</div>
</div>
What is the syntax problem?
For accordian you don't need to specify href and id. Use UI bootstrap.
https://angular-ui.github.io/bootstrap/#/accordion
http://embed.plnkr.co/3y0Rq1/

syntax to use binding expression inside href

I have created a nested accordian bootstrap panel. On clicking the parent(top most) panel heading - dropdown works fine but on clicking the child(sub panel heading) panel heading-dropdown wont work. I am retriving panel contents(sub panel heading and body) using angular $http.get rest api.
In this case, i think i did a mistake in syntax while linking the panel heading and panel body with its href and id attribute values( ng-href="{{productline_name}}" and id="{{productline_name}}" ).
Below code is placed inside top most panel body to create nested panel
<div class="panel-group col-lg-3" style="background-color:#505054;height:450px" id="accordion">
<div class="panel" style="background-color:#505054;color:#C1C1C1;border-bottom: 1px solid #eee;">
<h6>Clear Filter</h6>
</div>
<div class="panel" style="background-color:#505054;color:white;border-bottom: 1px solid white;">
<div class="panel-heading">
<h6>
<div class="accordion-toggle" data-toggle="collapse" data-parent="#accordion" href="#collapse1">PRODUCT</div>
</h6>
</div>
<div id="collapse1" class="panel-collapse collapse in">
<div class="panel-body">
<ul>
<li class="panel-title"><a ng-click="cfilter('all')"><h5>All Records</h5></a></li>
<li ng-repeat="pline in detpline" class="panel-group" id="accordion2">
<div class="panel" style="background-color:#505054;color:white;border-bottom: 1px solid white;">
<div class="panel-heading" ng-click="plinefunc(pline.productline_name)">
<h6>
<div class="accordion-toggle" data-toggle="collapse" data-parent="#accordion2" ng-href="{{productline_name}}">{{pline.productline_name}}</div>
</h6>
</div>
<div id="{{productline_name}}" class="panel-collapse collapse">
<div class="panel-body">
<ul>
<li class="panel-title" ng-repeat="prd in detp"><a ng-click="cfilter(prd.product_name)"><h5>{{prd.product_name}}</h5></a></li>
</ul>
</div>
</div>
</div>
</li>
</ul>
</div>
</div>
</div>
</div>
Can any one help in this? what is the correct syntax to use to link panel heading and panel body via binding expresion?
Note: I am using binding expression for linking only to avoid opening all other sub panel heading contents on-clicking one of the sub panel heading.

Override webpage centered

I am using Angular Drywall to build my website. The default alignment of this is in the center. However, the template I want to render, requires to occupy 100% of the body width.
I used in css,
body{
width:100%;
margin-left:0;
padding-left: 0;
background-color: yellow;
}
This does render yellow to the entire viewing area. But the content in my template is still rendered to the center.
How do I override that ?
Thank you.
EDIT:
I do not have a lot of code. I have attached two picture of how it looks and how I want it to look.
<h1>Work Bench </h1>
<div class="col-lg-3 left">
<div class="input-group resize">
<input type="text" class="form-control" placeholder="Search Element"/>
<span class="input-group-addon">
<i class="fa fa-search"></i>
</span>
</div>
</div>
Bootstrap solution:
Close the container or container-fluid div and reopen it after placing your content betweeen.
<div class="container">
<!-- navigation bar stuff -->
</div>
your elements here
<div class="container">
<!-- footer stuff -->
</div>
Bootply example

Resources