Angular states not showing amcharts after switching back to that state - angularjs

I have two charts divs in html which I am able to display first time. but when my state changes and I come back to the state where I displayed charts. Then charts are not shown. I think I have to re-attach the dataProvider and render it again but i don't know how.
this is my controller
.controller('HomeCtrl', function ($location,$window) {
AmCharts.makeChart("chartdiv-pie", {
"type": "pie",
"theme": "light",
"dataProvider": [{
"title": "20%",
"value": 3852,
"color": "#18aa9f"
}, {
"title": "40%",
"value": 3899,
"color": "#e65548"
},
{
"title": "40%",
"value": 4899,
"color": "#e1e3e4"
}
],
"title": "AmCharts",
"color": "black",
"titleField": "title",
"valueField": "value",
"radius": "25%",
"outlineAlpha":0,
"innerRadius": "40%",
"balloonText": "[[value]]",
"labelText": "[[title]]",
"labelsEnabled": true,
"colorField": "color",
"labelText": "[[title]]",
"export": {
"enabled": true
},
});
var chart = AmCharts.makeChart( "chartdiv-male", {
"type": "serial",
"addClassNames": true,
"theme": "light",
"autoMargins": false,
"marginLeft": 30,
"marginRight": 8,
"marginTop": 10,
"marginBottom": 26,
"balloon": {
"adjustBorderColor": false,
"horizontalPadding": 10,
"verticalPadding": 8,
"color": "#ffffff"
},
"dataProvider": [ {
"year": "Pos",
"income": 30.1,
"color": "#FF0F00",
"expenses": 34.9,
}, {
"year": "Neg",
"income": 29.5,
"expenses": 31.1
}, {
"year": "Neu",
"income": 30.6,
"expenses": 28.2,
"dashLengthLine": 5,
"columnColor": 'green'
} ],
"valueAxes": [ {
"axisAlpha": 0,
"position": "left"
} ],
"startDuration": 1,
"graphs": [ {
"alphaField": "alpha",
"balloonText": "<span style='font-size:12px;'>[[title]] in [[category]]:<br><span style='font-size:20px;'>[[value]]</span> [[additional]]</span>",
"fillAlphas": 1,
"title": "Income",
"type": "column",
"valueField": "income",
"dashLengthField": "dashLengthColumn"
}, ],
"categoryField": "year",
"categoryAxis": {
"gridPosition": "start",
"axisAlpha": 0,
"tickLength": 0
},
"export": {
"enabled": true
}
} );
}
these are my states
.state('home.stats', {
url:'/stats',
templateUrl: 'views/stats.html',
controller: 'StatsCtrl',
controllerAs: 'stats'
})
.state('home.posts', {
url:'/posts',
templateUrl: 'views/posts.html',
controller: 'PostsCtrl',
controllerAs: 'posts'
});

Related

I want to align x axis labels with its respective bar in bar chart of highcharts. Currently, the labels are one line above the bars

I want to align x axis labels with its respective bar in bar chart of highcharts as it is not aligned as seen in picture.
code -
"chartOptions": {
"xAxis":
{
"type": "category",
"labels": {
"align": "left",
"reserveSpace": true
},
"scrollbar": {
"enabled": true
},
"max": 4,
"min": 0,
"minorTickLength": 0,
"tickLength": 0
} ,
"plotOptions": {
"bar": {
"grouping": false
}
},
"yAxis": [
{
"title": {
"text": "Blocked Orders Volume"
},
"labels": {
"format": "{value}"
}
},
{
"title": {
"text": "Blocked Orders Value"
},
"labels": {
"format": "${value}"
},
"opposite": true
}
],
"colors": [
"#14AFF1",
"#FC7500"
],
"series": [
{
"borderRadius": 0,
"pointWidth": 18
},
{
"type": "spline",
"yAxis": 1
}
],
"tooltip": {
"enabled": true,
"shared": true
},
"legend": {
"enabled": true,
"itemStyle": {
"color": "#666668",
"font-family": "Poppins",
"fontWeight": "normal"
}
}
},
I want x axis labels to line up with bars

get dynamic data from the slot ? not added resolutionsPerAuthority's dynamic element in the list

I am trying to get dynamic data from the slot
As per documentation and my basic test I am sending directive from launch request as like :
{'version': '1.0', 'response': {'outputSpeech': {'type': 'SSML', 'ssml': '<speak> Hi, welcome to developement dynamic slot. <break time="800ms"/>Please tell me the product name you would be interested in</speak>'}, 'card': {'type': 'Simple', 'title': 'Choose a Medicine.', 'content': 'Pick a Medicine.'}, 'reprompt': {'outputSpeech': {'type': 'SSML', 'ssml': '<speak><break time="5s"/>I am HERE to help You, Please tell me the product and country names you would be interested in.</speak>'}}, 'shouldEndSession': False}, 'directives': [{'type': 'Dialog.UpdateDynamicEntities', 'updateBehavior': 'REPLACE', 'types': [{'name': 'products', 'values': [{'id': 'grnTea', 'name': {'value': 'green tea', 'synonyms': ['matcha']}}, {'id': 'oolTea', 'name': {'value': 'oolong', 'synonyms': ['chinese tea', 'black dragon tea']}}]}]}]}
and when I'm trying to get data which is not statically store in a slot but added in directive slot value.
returns following output :
{ "version": "1.0", "session": { "new": false, "sessionId": "amzn1.echo-api.session.671181ed-1e50-4e4c-b70e-4d854fe7cb78", "application": { "applicationId": "amzn1.ask.skill.c35cd12c-6845-473e-be58-9b1139ee0adb" }, "user": { "userId": "amzn1.ask.account.sadasdsa", "permissions": { "consentToken": "eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiIsImtpZCI6IjEifQ..XyWgyUIjDzzlZ12CR0lbZid6GxwZZYBgarlV-9difbkFjOTxrcvS9lJYWo-Db3wo-fIdXb_jZkCAJBtYPggqnJhLyyC-EDa0_u9aARKthF1_nkbLh5zDOHDb8MyyOYro4BJlqm4XBNd1qyeQUV2M4fdca1YSEnbEun_6kWOKeFRS-14zcwMj5E-MHcBbeDX799A_kay82kS8VGeMhSUsXPTZFrwOKHcFweJTqXFNOkBxME8kAFfS1JB5MNbA3TujVIsIgTBSNQaJeHRksConKt0u06ATrjffzFkcmbxDT5HoJH4NqDgS0y_GdtaeXQM3LJ-MN0-_DMX2QVEaL6kUUw" } } }, "context": { "System": { "application": { "applicationId": "amzn1.ask.skill.c35cd12c-6845-473e-be58-9b1139ee0adb" }, "user": { "userId": "amzn1.ask.account.aasdasdasdasdas", "permissions": { "consentToken": "eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiIsImtpZCI6IjEifQ.asdjaskdhas.XyWgyUIjDzzlZ12CR0lbZid6GxwZZYBgarlV-9difbkFjOTxrcvS9lJYWo-Db3wo-fIdXb_jZkCAJBtYPggqnJhLyyC-EDa0_u9aARKthF1_nkbLh5zDOHDb8MyyOYro4BJlqm4XBNd1qyeQUV2M4fdca1YSEnbEun_6kWOKeFRS-14zcwMj5E-MHcBbeDX799A_kay82kS8VGeMhSUsXPTZFrwOKHcFweJTqXFNOkBxME8kAFfS1JB5MNbA3TujVIsIgTBSNQaJeHRksConKt0u06ATrjffzFkcmbxDT5HoJH4NqDgS0y_GdtaeXQM3LJ-MN0-_DMX2QVEaL6kUUw" } }, "device": { "deviceId": "amzn1.ask.device.ajshdjkhasjkhdkjsahkasdhjasd", "supportedInterfaces": {} }, "apiEndpoint": "https://api.eu.amazonalexa.com", "apiAccessToken": "eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiIsImtpZCI6IjEifQ.asdhjashjdhajsd.RQhzWmnhN9K_dCbsFXBPPoLVzuwe5BWjAruwJNF1pVr11PiygVgQ64W3CNng2sK1thT2tl6r3GuRtG-1133Aw1KPWtMuHElu7CTrFfgAqW8blpK37PJIvPMOUGBw1rbrgCTMdy8Ua7qSFV_Y_wlOJaV3-apDGBqhQKE_-dE-ntWYZuIySlY3l8hBs_66eELS-LiL5DEDJk1hfvC2C6ZFB7A7P8mx4Hb71km-lYaElJS0-FDP0C-LdSp6dCbzV23W4JehtTGL4kJ1JEQgWyuNAAkt_HmPcEYlPp8T5RFceDuVuz-ZZBFyiVKuAN8VmxyFsmnC3SXi4yb3RKm1SCcorg" }, "Viewport": { "experiences": [ { "arcMinuteWidth": 246, "arcMinuteHeight": 144, "canRotate": false, "canResize": false } ], "shape": "RECTANGLE", "pixelWidth": 1024, "pixelHeight": 600, "dpi": 160, "currentPixelWidth": 1024, "currentPixelHeight": 600, "touch": [ "SINGLE" ], "video": { "codecs": [ "H_264_42", "H_264_41" ] } }, "Viewports": [ { "type": "APL", "id": "main", "shape": "RECTANGLE", "dpi": 160, "presentationType": "STANDARD", "canRotate": false, "configuration": { "current": { "video": { "codecs": [ "H_264_42", "H_264_41" ] }, "size": { "type": "DISCRETE", "pixelWidth": 1024, "pixelHeight": 600 } } } } ] }, "request": { "type": "IntentRequest", "requestId": "amzn1.echo-api.request.0f3b51f1-880b-483f-8410-3210e81e5b59", "timestamp": "2020-01-01T11:48:09Z", "locale": "en-IN", "intent": { "name": "productcheck", "confirmationStatus": "NONE", "slots": { "products": { "name": "products", "value": "green tea", "resolutions": { "resolutionsPerAuthority": [ { "authority": "amzn1.er-authority.echo-sdk.amzn1.ask.skill.c35cd12c-6845-473e-be58-9b1139ee0adb.products", "status": { "code": "ER_SUCCESS_NO_MATCH" } } ] }, "confirmationStatus": "NONE", "source": "USER" } } } } }
It's not added resolutions resolutionsPerAuthority's second(dynamic) element in the list.
anybody can help me out from this problem?
I tested your added directive exactly as pasted and the dynamic entity resolved as expected:
"slots": {
"products": {
"name": "products",
"value": "matcha",
"resolutions": {
"resolutionsPerAuthority": [
{
"authority": "amzn1.er-authority.echo-sdk.amzn1.ask.skill.****.products",
"status": {
"code": "ER_SUCCESS_NO_MATCH"
}
},
{
"authority": "amzn1.er-authority.echo-sdk.dynamic.amzn1.ask.skill.****.products",
"status": {
"code": "ER_SUCCESS_MATCH"
},
"values": [
{
"value": {
"name": "green tea",
"id": "grnTea"
}
}
]
}
]
},
"confirmationStatus": "NONE",
"source": "USER"
}
}
Could you share your skill's interaction model to investigate further?

React js: Nivo Pie chart not showing up

i'm working in react js with nivo pie chart i'm using the exact code as provided in the documentation but when i start server the chart is not rendered and it displays empty page and there is no error in the console and server terminal.
code:
import React from 'react';
import { render } from 'react-dom'
import { ResponsivePie } from '#nivo/pie'
var data = [
{
"id": "rust",
"label": "rust",
"value": 576,
"color": "hsl(167, 70%, 50%)"
},
{
"id": "javascript",
"label": "javascript",
"value": 129,
"color": "hsl(119, 70%, 50%)"
},
{
"id": "java",
"label": "java",
"value": 422,
"color": "hsl(253, 70%, 50%)"
},
{
"id": "hack",
"label": "hack",
"value": 71,
"color": "hsl(307, 70%, 50%)"
},
{
"id": "erlang",
"label": "erlang",
"value": 354,
"color": "hsl(187, 70%, 50%)"
}
];
render((
<ResponsivePie
data={data}
margin={{
"top": 40,
"right": 80,
"bottom": 80,
"left": 80
}}
innerRadius={0.5}
padAngle={0.7}
cornerRadius={3}
colors="nivo"
colorBy="id"
borderWidth={1}
borderColor="inherit:darker(0.2)"
radialLabelsSkipAngle={10}
radialLabelsTextXOffset={6}
radialLabelsTextColor="#333333"
radialLabelsLinkOffset={0}
radialLabelsLinkDiagonalLength={16}
radialLabelsLinkHorizontalLength={24}
radialLabelsLinkStrokeWidth={1}
radialLabelsLinkColor="inherit"
slicesLabelsSkipAngle={10}
slicesLabelsTextColor="#333333"
animate={true}
motionStiffness={90}
motionDamping={15}
defs={[
{
"id": "dots",
"type": "patternDots",
"background": "inherit",
"color": "rgba(255, 255, 255, 0.3)",
"size": 4,
"padding": 1,
"stagger": true
},
{
"id": "lines",
"type": "patternLines",
"background": "inherit",
"color": "rgba(255, 255, 255, 0.3)",
"rotation": -45,
"lineWidth": 6,
"spacing": 10
}
]}
fill={[
{
"match": {
"id": "ruby"
},
"id": "dots"
},
{
"match": {
"id": "c"
},
"id": "dots"
},
{
"match": {
"id": "go"
},
"id": "dots"
},
{
"match": {
"id": "python"
},
"id": "dots"
},
{
"match": {
"id": "scala"
},
"id": "lines"
},
{
"match": {
"id": "lisp"
},
"id": "lines"
},
{
"match": {
"id": "elixir"
},
"id": "lines"
},
{
"match": {
"id": "javascript"
},
"id": "lines"
}
]}
legends={[
{
"anchor": "bottom",
"direction": "row",
"translateY": 56,
"itemWidth": 100,
"itemHeight": 18,
"itemTextColor": "#999",
"symbolSize": 18,
"symbolShape": "circle",
"effects": [
{
"on": "hover",
"style": {
"itemTextColor": "#000"
}
}
]
}
]}
/>
), document.getElementById('root'));
this is first time i'm working on charts in react js.
What i'm doing wrong any help will be appreciated.
Thanks.
I think you maybe forget to set the height of the father component of ResponsivePie.Here is the explain in the document
make sure parent container have a defined height when using responsive component,otherwise height will be 0 and no chart will be rendered
like this:
<div style={{height: 200}}>
<ResponsivePie .../>
</div>

angular ui tree for complex json

How to create angular ui tree for complex json?
[
{
"name": "bmw",
"model": "x3",
"specs": [
{
"name": "bmw",
"maxspeed": 350,
"minspeed": 0,
"model": "x3",
"type": "car"
},
{
"value": 30,
"name": "bmw",
"maxspeed": 350,
"minspeed": 0,
"model": "x3",
"type": "car"
}
],
"available": true,
"price": 50
},
{
"name": "audi",
"model": "r8",
"specs": [
{
"color": [
{
"value": "red",
"price": 100
},
{
"value": [
"white",
"black"
],
"price": 200
}
],
"maxspeed": 330,
"minspeed": 0,
"type": "car"
},
{
"color": [
{
"value": "blue",
"price": 300
},
{
"value": [
"yellow",
"gold"
],
"price": 500
}
],
"maxspeed": 330,
"minspeed": 0,
"type": "car"
}
],
"available": true
}
]

jqGrid 4.4.4 How to use the filterToolbar with complex objects with formatted columns?

I would like to have the filterToolbar filter the Sports? How can this be done? Currently, It returns nothing. The Sports column has concatenated all CatagoryID=1 in the data, example only: "Baseball, Chess, Hockey". The data object is complex in that it has arrays of other objects and has single elements too, like Sex or LastName. Sports is an array.
This is my working code...
$(document).ready(function() {
var mydata = [{
"Addresses": [],
"PhoneNumbers": [],
"Certifications": [],
"Sports": [{
"CategoryID": 1,
"Value": "Football"
}, {
"CategoryID": 2,
"Value": "Chess"
}],
"Notes": [],
"Id": "42",
"FirstName": "Tony",
"LastName": "Fischer",
"Sex": "M"
}, {
"Addresses": [],
"PhoneNumbers": [],
"Certifications": [],
"Sports": [{
"CategoryID": 1,
"Value": "Football"
}, {
"CategoryID": 1,
"Value": "Soccer"
}],
"Notes": [],
"Id": "61",
"FirstName": "Joe",
"LastName": "Falcon",
"Sex": "M"
}, {
"Addresses": [],
"PhoneNumbers": [],
"Certifications": [],
"Sports": [{
"CategoryID": 1,
"Value": "Football"
}, {
"CategoryID": 1,
"Value": "Soccer"
}],
"Notes": [],
"Id": "89",
"FirstName": "Judith",
"LastName": "Tinis",
"Sex": "F"
}, {
"Addresses": [],
"PhoneNumbers": [],
"Certifications": [],
"Sports": [{
"CategoryID": 3,
"Value": "Pingpong"
}, {
"CategoryID": 1,
"Value": "Hockey"
}, {
"CategoryID": 1,
"Value": "Checkers"
}],
"Notes": [],
"Id": "89",
"FirstName": "Boris",
"LastName": "Spassky",
"Sex": "M"
}, {
"Addresses": [],
"PhoneNumbers": [],
"Certifications": [],
"Sports": [{
"CategoryID": 1,
"Value": "Football"
}, {
"CategoryID": 2,
"Value": "Chess"
}],
"Notes": [],
"Id": "77",
"FirstName": "Betty",
"LastName": "Bundtcake",
"Sex": "F"
}, {
"Addresses": [],
"PhoneNumbers": [],
"Certifications": [],
"Sports": [{
"CategoryID": 1,
"Value": "Football"
}, {
"CategoryID": 1,
"Value": "Baseball"
}],
"Notes": [],
"Id": "88",
"FirstName": "Henry",
"LastName": "Aaron",
"Sex": "M"
}, {
"Addresses": [],
"PhoneNumbers": [],
"Certifications": [],
"Sports": [{
"CategoryID": 1,
"Value": "Football"
}, {
"CategoryID": 1,
"Value": "Soccer"
}],
"Notes": [],
"Id": "99",
"FirstName": "MaryLou",
"LastName": "Terrin",
"Sex": "F"
}, {
"Addresses": [],
"PhoneNumbers": [],
"Certifications": [],
"Sports": [{
"CategoryID": 3,
"Value": "Pingpong"
}, {
"CategoryID": 1,
"Value": "Hockey"
}, {
"CategoryID": 1,
"Value": "Checkers"
}],
"Notes": [],
"Id": "22",
"FirstName": "Ralph",
"LastName": "Parins",
"Sex": "M"
}, {
"Addresses": [],
"PhoneNumbers": [],
"Certifications": [],
"Sports": [{
"CategoryID": 1,
"Value": "Risk"
}],
"Notes": [],
"Id": "35",
"FirstName": "Svetzor",
"LastName": "Gligorich",
"Sex": "M"
}];
$("#mygrid").jqGrid({
datatype: "local",
data: mydata,
loadOnce: true,
colNames: ['Id', 'First', 'Last', 'Gender', 'Sports'],
colModel: [{
name: 'Id',
index: 'Id',
hidden: true,
key: true,
editable: false
}, {
name: 'FirstName',
index: 'FirstName',
width: 100,
sortable: true
}, {
name: 'LastName',
index: 'LastName',
width: 120,
sortable: true
}, {
name: 'Sex',
index: 'Sex',
width: 130,
sortable: true
}, {
name: 'Sports',
width: 250,
jsonmap: 'Sports.0',
// this formatter says if array data has something and it's CategoryID is 1, then join all the elements' 'Value' seperated by a ','
formatter: function(cellvalue) {
return cellvalue.length == 0 ? '' : $.map(cellvalue, function(obj) {
return obj.CategoryID == 1 ? obj.Value : null
}).join(', ');
}
}],
sortname: 'LastName',
pager: $('#pager'),
rowNum: 5,
rowList: [5, 10, 20, 50],
sortorder: "desc",
viewrecords: true,
caption: "Team Members"
});
$("#mygrid").jqGrid('filterToolbar', {
stringResult: true,
searchOnEnter: false,
defaultSearch: "cn"
});
});
html,
body {
font-size: 75%;
}
.ui-jqgrid .ui-search-table .ui-search-input > input,
.ui-jqgrid .ui-search-table .ui-search-input > select {
display: block;
-moz-box-sizing: border-box;
-webkit-box-sizing: border-box;
box-sizing: border-box;
}
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Griddy</title>
<link rel="stylesheet" type="text/css" href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.10.3/themes/redmond/jquery-ui.css" />
<link rel="stylesheet" type="text/css" href="http://www.ok-soft-gmbh.com/jqGrid/jquery.jqGrid-4.4.4/css/ui.jqgrid.css" />
<style type="text/css">
html, body {
font-size: 75%;
}
.ui-jqgrid .ui-search-table .ui-search-input > input, .ui-jqgrid .ui-search-table .ui-search-input > select {
display: block;
-moz-box-sizing: border-box;
-webkit-box-sizing: border-box;
box-sizing: border-box;
}
</style>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/2.0.2/jquery.min.js"></script>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.10.3/jquery-ui.min.js"></script>
<script type="text/javascript" src="http://www.ok-soft-gmbh.com/jqGrid/jquery.jqGrid-4.4.4/js/i18n/grid.locale-en.js"></script>
<script type="text/javascript">
//$.jgrid.no_legacy_api = true;
//$.jgrid.useJSON = true;
</script>
<script type="text/javascript" src="http://www.ok-soft-gmbh.com/jqGrid/jquery.jqGrid-4.4.4/js/jquery.jqGrid.src.js"></script>
</head>
<body>
<table id="mygrid"></table>
<div id="pager" style="text-align:left;"></div>
<div id="pager"></div>
</body>
</html>

Resources