I am attempting to load fusion charts into an xPage. Following this tutorial http://docs.fusioncharts.com/tutorial-getting-started-your-first-charts-building-your-first-chart.html
The chart is not loading and is showing chart loading. At the bottom of the page I get a few error messages in the js console.
Here is the code I am using for the page. (url changed from actual url)
<xp:this.resources>
<xp:script src="https://URL/Field/fplan.nsf/fusioncharts/js/fusioncharts.js"
clientSide="true">
</xp:script>
<xp:script
src="https://URL/Field/fplan.nsf/fusioncharts/js/themes/fusioncharts.theme.fint.js"
clientSide="true">
</xp:script>
</xp:this.resources>
<xp:scriptBlock type="text/javascript">
<xp:this.value><![CDATA[
FusionCharts.ready(function(){
var revenueChart = new FusionCharts({
"type": "column2d",
"renderAt": "chartContainer",
"width": "500",
"height": "300",
"dataFormat": "json",
"dataSource": {
"chart": {
"caption": "Monthly revenue for last year",
"subCaption": "Harry's SuperMart",
"xAxisName": "Month",
"yAxisName": "Revenues (In USD)",
"theme": "fint"
},
"data": [
{
"label": "Jan",
"value": "420000"
},
{
"label": "Feb",
"value": "810000"
},
{
"label": "Mar",
"value": "720000"
},
{
"label": "Apr",
"value": "550000"
},
{
"label": "May",
"value": "910000"
},
{
"label": "Jun",
"value": "510000"
},
{
"label": "Jul",
"value": "680000"
},
{
"label": "Aug",
"value": "620000"
},
{
"label": "Sep",
"value": "610000"
},
{
"label": "Oct",
"value": "490000"
},
{
"label": "Nov",
"value": "900000"
},
{
"label": "Dec",
"value": "730000"
}
]
}
});
revenueChart.render();
})]]></xp:this.value>
</xp:scriptBlock>
<div id="chartContainer">FusionCharts XT will load here!</div>
Uncaught TypeError: Cannot set property 'desc' of undefined fusioncharts.js:436(anonymous function) fusioncharts.js:436v.core fusioncharts.js:20v.registrars.module fusioncharts.js:19v.extend.register fusioncharts.js:22(anonymous function) fusioncharts.js:236
Uncaught TypeError: Cannot read property 'fn' of undefined fusioncharts.js:437(anonymous function) fusioncharts.js:437v.core fusioncharts.js:20v.registrars.module fusioncharts.js:19v.extend.register fusioncharts.js:22(anonymous function) fusioncharts.js:437
Uncaught TypeError: undefined is not a function fusioncharts.js:129(anonymous function) fusioncharts.js:129c fusioncharts.js:32H fusioncharts.js:32b.triggerEvent fusioncharts.js:36d.raiseEvent fusioncharts.js:36d.extend.render fusioncharts.js:70(anonymous function) chart.xsp:88(anonymous function)
If I drop an HTML file into the NSF as a file in the webcontent folder I am able to load the chart so at least I know the fusionchart files are sound.
Any assistance in how to implement this would be appreciated.
I guess I would start by moving the chart initialization code into a client side script library and adding that as a resource to see if that makes a difference.
Try loading the script in the following way:
<xp:this.resources>
<xp:headTag tagName="script">
<xp:this.attributes>
<xp:parameter name="type" value="text/javascript" />
<xp:parameter name="src" value=
"https://URL/Field/fplan.nsf/fusioncharts/js/fusioncharts.js" />
</xp:this.attributes>
</xp:headTag>
<xp:headTag tagName="script">
<xp:this.attributes>
<xp:parameter name="type" value="text/javascript" />
<xp:parameter name="src" value=
"https://URL/Field/fplan.nsf/fusioncharts/js/themes/fusioncharts.theme.fint.js" />
</xp:this.attributes>
</xp:headTag>
</xp:this.resources>
Related
For my teaching notes I am trying to implement this vega-lite example in Altair:
{
"data": {"url": "data/seattle-weather.csv"},
"layer": [{
"params": [{
"name": "brush",
"select": {"type": "interval", "encodings": ["x"]}
}],
"mark": "bar",
"encoding": {
"x": {
"timeUnit": "month",
"field": "date",
"type": "ordinal"
},
"y": {
"aggregate": "mean",
"field": "precipitation",
"type": "quantitative"
},
"opacity": {
"condition": {
"param": "brush", "value": 1
},
"value": 0.7
}
}
}, {
"transform": [{
"filter": {"param": "brush"}
}],
"mark": "rule",
"encoding": {
"y": {
"aggregate": "mean",
"field": "precipitation",
"type": "quantitative"
},
"color": {"value": "firebrick"},
"size": {"value": 3}
}
}]
}
I getting the separate charts (bar and rule to work) was easy, but I run into issues in making mark_rule interactive.
import altair as alt
from vega_datasets import data
df = data.seattle_weather()
selection = alt.selection_interval(encodings=['x'])
base = alt.Chart(df).add_selection(selection)
bar_i = base.mark_bar().encode(
x="month(date):T",
y="mean(precipitation):Q",
opacity=alt.condition(selection, alt.value(1.0), alt.value(0.7)))
rule_i = base.mark_rule().transform_filter(selection).encode(y="mean(precipitation):Q")
(bar_i + rule_i).properties(width=600)
The error reads
Javascript Error: Duplicate signal name: "selector013_scale_trigger"
This usually means there's a typo in your chart specification. See the javascript console for the full traceback.
It looks like the chart you're interested in creating is part of Altair's example gallery: https://altair-viz.github.io/gallery/selection_layer_bar_month.html
import altair as alt
from vega_datasets import data
source = data.seattle_weather()
brush = alt.selection(type='interval', encodings=['x'])
bars = alt.Chart(source).mark_bar().encode(
x='month(date):O',
y='mean(precipitation):Q',
opacity=alt.condition(brush, alt.OpacityValue(1), alt.OpacityValue(0.7)),
).add_selection(
brush
)
line = alt.Chart(source).mark_rule(color='firebrick').encode(
y='mean(precipitation):Q',
size=alt.SizeValue(3)
).transform_filter(
brush
)
bars + line
The error you're seeing comes from the fact that base includes the selection, and both layers are derived from base, so the same selection is declared twice within the single chart.
{
"wrapper": "section",
"className": "row",
"hideExpression":"function($viewValue, $modelValue, scope){ return (scope.model['Application__c']['Years1__c'] && (parseFloat(scope.model['Application__c']['Years1__c']+'x.'+scope.model['Application__c']['Months1__c'])+parseFloat(scope.model['Application__c']['Years__c']+'.'+scope.model['Application__c']['Months__c']))>2); }" ,
"fieldGroup": [ {
"key": "Application__c.City_Prev1__c",
"type": "alphabet",
"hideExpression":"function($viewValue, $modelValue, scope){ return !scope.model['Application__c']['Years1__c'] }" ,
"className": "col-xs-7 col-sm-6 col-md-5 col-lg-5",
"templateOptions": {
"label": "City",
"required": true,
"maxlength": 20,
"objectName": "Application__c",
"fieldName": "City_Prev1__c"
}
}]
}
In the above formly json, how can make hide expression as a function or how can I call a function from outside
Please refer the link below
**Function constructor **
The Function constructor creates a new Function object. Calling the constructor directly can create functions dynamically, but suffers from security and performance issues similar to eval.
So I have the following chart :
As you can See I have little images(annotations) in the chart and am using the built-in function to export the chart to PDF(As I cant find code to allow me to do it via the controller or via iTextSharp) - This works great though, as it gives a number of choices to export to(PDF,PNG,JPG etc.) - However, the little images as you see are not displayed when exported to PDF for example.
Is there a property that needs to be set such as the one to allow the exporting to be done : exportenabled='1' ?
Thank in advance.
#AxleWack
Try this code -
<html>
<head>
<title>My first chart using FusionCharts Suite XT</title>
<script type="text/javascript" src="http://static.fusioncharts.com/code/latest/fusioncharts.js?cacheBust=82"></script>
<script type="text/javascript" src="http://static.fusioncharts.com/code/latest/themes/fusioncharts.theme.fint.js?cacheBust=82"></script>
<script type="text/javascript">
FusionCharts.ready(function(){
var revenueChart = new FusionCharts({
"type": "column2d",
"renderAt": "chartContainer",
"width": "500",
"height": "300",
"dataFormat": "json",
"dataSource": {
"chart": {
"caption": "Monthly revenue for last year",
"subCaption": "Harry's SuperMart",
"xAxisName": "Month",
"yAxisName": "Revenues (In USD)",
"exportEnabled": "1",
"canvasBgAlpha": "50",
"bgImageVAlign": "middle",
"bgImageHAlign": "middle",
"bgImageScale": "120",
"bgImage": "http://localhost:8888/Sample/fc.png",
"theme": "fint"
},
"data": [
{
"label": "Jan",
"value": "420000"
},
{
"label": "Feb",
"value": "810000"
},
{
"label": "Mar",
"value": "720000"
},
{
"label": "Apr",
"value": "550000"
},
{
"label": "May",
"value": "910000"
},
{
"label": "Jun",
"value": "510000"
},
{
"label": "Jul",
"value": "680000"
},
{
"label": "Aug",
"value": "620000"
},
{
"label": "Sep",
"value": "610000"
},
{
"label": "Oct",
"value": "490000"
},
{
"label": "Nov",
"value": "900000"
},
{
"label": "Dec",
"value": "730000"
}
]
}
});
revenueChart.render();
})
</script>
</head>
<body>
<center><div id="chartContainer">FusionCharts XT will load here!</div></center>
</body>
</html>
Put this HTML in the root directory of your localhost under folder name Sample (i.e., rootDir -> Sample -> index.html).
Here, the image name is 'fc.png'. Put an image in the Sample folder (i.e., rootDir -> Sample -> fc.png).
Make sure if you use localhost in the domain name to access the HTML page through browser (eg. http://localhost:8888/Sample/index.html), give value for bgImage attribute as http://localhost:8888/Sample/fc.png, else if you use IP address in domain name to access the HTML page through browser, for eg. http://192.168.0.160:8888/Sample/index.html, the value for bgImage atrribute will be like - http://192.168.0.160:8888/Sample/fc.png.
The domain name should be same for both the image and html.
The above is the solution for local setup. You may also use FusionCharts exporter handlers for various technologies like ASP .Net, php, Ruby On Rails, Java EE.
Now try exporting the chart, it will be exported with the images.
Thank You! Hope I have been able to explain you properly. :)
I have mule flow which selects few records from database tables which looks like below.
StudentID Subject Mark
1 Maths 98
2 Literature 62
1 Science 56
1 Anatomy 63
3 Zoology 38
2 Algebra 63
Here i need to group the records based on studentID and need to send for further processing. Hence i have placed splitter component immediate after database node. But in MEL expression how can we group the records ?
Is there any other best way to do this ESB mule ?
Update - I need to split the message based on StudentID (group by). I found groovy can do grouping. But whether we can split the messages using groovy.
I would create a Java object and implement callable. Use this method to alter the payload. Then I would use a second database component and use the payload object (MEL) in the second query.
This object transforms data from a Database component output flow to a hybrid object that's used to display JSON with an embedded array of child data.
https://github.com/dlwhitehurst/modusbox-orders/blob/master/src/main/java/org/dlw/transport/OrdersTransformSingleton.java
Check out the return on the callable method and see how you can "transform" the data yourself.
Here's the snippet in the mule config that instances the needed Java component.
<spring:beans>
<spring:bean id="ordersTransform" name="OrdersTransformSingleton"
class="org.dlw.transport.OrdersTransformSingleton" scope="singleton">
</spring:bean>
<spring:bean id="jdbcDataSource" class="org.enhydra.jdbc.standard.StandardDataSource" destroy-method="shutdown">
<spring:property name="driverName" value="com.mysql.jdbc.Driver"/>
<spring:property name="url" value="${database.url}"/>
</spring:bean>
</spring:beans>
The object is used in the flow like this ...
<flow name="get:/orders:api-config">
<set-payload value="[
{
"orderId": 1233,
"placementDate": "2016-06-02",
"customerName": "Sally Hansen",
"orderItems":[
{
"orderItemId": 1323,
"orderId": 438577,
"itemId": 23058,
"itemName": "Salt",
"itemCount": 3,
"qtyItemCost": "$2.76"
},
{
"orderItemId": 1323,
"orderId": 438577,
"itemId": 23058,
"itemName": "Pepper",
"itemCount": 3,
"qtyItemCost": "$8.79"
}
]
},
{
"orderId": 1233,
"placementDate": "2016-06-02",
"customerName": "Billy Wilson",
"orderItems":[
{
"orderItemId": 1323,
"orderId": 438577,
"itemId": 23058,
"itemName": "Wheat Flour",
"itemCount": 3,
"qtyItemCost": "$10.12"
},
{
"orderItemId": 1323,
"orderId": 438577,
"itemId": 23058,
"itemName": "Tomato Paste",
"itemCount": 3,
"qtyItemCost": "$9.21"
}
]
}
]" doc:name="Set Payload"/>
<db:select config-ref="MySQL_Configuration" doc:name="Database">
<db:parameterized-query><![CDATA[SELECT a.orderId, a.customerName, a.placementDate, b.orderItemId, b.itemId, c.itemName, b.itemCount, c.itemCost FROM modusbox.orders a, modusbox.orderitems b, modusbox.items c WHERE a.orderId = b.orderId AND b.itemId = c.itemId]]></db:parameterized-query>
</db:select>
<component doc:name="Java">
<spring-object bean="OrdersTransformSingleton" />
</component>
<json:object-to-json-transformer doc:name="Object to JSON"/>
<logger level="INFO" doc:name="Logger"/>
</flow>
Better place dataweave component and use 'groupBy' logic.
https://docs.mulesoft.com/mule-user-guide/v/3.7/dataweave-reference-documentation#group-by
DataWeave is the right option for groupBy. If you don't have DataWeave as choice (using Community Edition), you can have a quick win with script engine groovy.
List which should be groupBy attribute mail
[
{
"mail": "smith#example.com",
"name": "lastname",
"value": "Smith"
},
{
"mail": "smith#example.com",
"name": "firstname",
"value": "John"
},
{
"mail": "doe#example.com",
"name": "lastname",
"value": "Doe"
},
{
"mail": "doe#example.com",
"name": "firstname",
"value": "Lisa"
}
]
Mule script component
<scripting:component>
<scripting:script engine="groovy">
<![CDATA[flowVars['recipients'].groupBy{it.mail}]]>
</scripting:script>
</scripting:component>
Result of groupBy mail
{
"smith#example.com": [
{
"mail": "smith#example.com",
"name": "lastname",
"value": "Smith"
},
{
"mail": "smith#example.com",
"name": "firstname",
"value": "John"
}
],
"doe#example.com": [
{
"mail": "doe#example.com",
"name": "lastname",
"value": "Doe"
},
{
"mail": "doe#example.com",
"name": "firstname",
"value": "Lisa"
}
]
}
Works fine with Mule 3.8.1 CE.
I have a login request and I want to assert a value from the response.
Here is this response:
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns="https://TUI.io/ns/20110812">
<soap:Body>
<login_resp>
<zato_env>
<cid>K07FKWJTWZMCNFJJBNDQVMZTW4TQ</cid>
<result>TUI_OK</result>
</zato_env>
<item>
<response>{"timestamp": "2015-11-30T17:05:37Z", "data": {"file": null, "token": "16e5fd", "endpoints": [{"label": "app1", "branc": [{"url": "/app1/v1.0/", "name": "test", }]}}, "success": true}</response>
</item>
</login_resp>
</soap:Body>
</soap:Envelope>
Now I want to assert:
file = null
endpoints = [{"label": "app1", "branc": [{"url": "/app1/v1.0/", "name": "test", }]
I tried this:
// check for RequestId element in response
def holder = new XmlHolder( messageExchange.responseContentAsXml )
assert holder["//ns1:file"] != null
I have not been able to resolve class XmlHolder.
Here is the groovy script, which will log the profile, endpoints
import com.eviware.soapui.support.XmlHolder
import net.sf.json.groovy.JsonSlurper
def soapResponse='''
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns="https://zato.io/ns/20130518">
<soap:Body>
<login_resp>
<zato_env>
<cid>K07FKWNDQVMZTW4JTWZMCNFJJBTQ</cid>
<result>ZATO_OK</result>
</zato_env>
<item>
<response>{"timestamp": "2015-11-30T17:05:37Z", "data": {"profile": null, "token": "1225555-sd18-4895-a037-d81ae2e273e2", "endpoints": [{"label": "app6", "branches": [{"url": "/app7/v1.0/", "name": "test", "api_version": "1.0", "label": "test"}], "appname": "app5"}, {"label": "app4", "branches": [{"url": "/gui/v1.0/", "name": "est", "api_version": "1.0", "label": "test"}], "appname": "gui"}, {"label": "app3", "branches": [{"url": "/app3/v1.0/", "name": "test", "api_version": "1.0", "label": "test"}], "appname": "app3"}, {"label": "app2", "branches": [{"url": "/app2/v1.0/", "name": "test", "api_version": "1.0", "label": "test"}], "appname": "app2"}, {"label": "app1", "branches": [{"url": "/app1/v1.0/", "name": "test", "api_version": "1.0", "label": "test"}], "appname": "app1"}]}, "success": true}</response>
</item>
</login_resp>
</soap:Body>
</soap:Envelope>
'''
def holder = new XmlHolder(soapResponse)
def response = holder.getNodeValue('//*:response')
def json = new JsonSlurper().parseText(response)
log.info json.data.profile
log.info json.data.endpoints
Similarly, you may query using . and json property any value as shown above.
For ex, to get timestamp - you may use -json.timestamp and to get token, json.data.token etc.,
EDIT: Based comments - intended to use in script assertion to handle response dynamically.
import com.eviware.soapui.support.XmlHolder
import net.sf.json.groovy.JsonSlurper
def soapResponse = messageExchange.responseContent
def holder = new XmlHolder(soapResponse)
def response = holder.getNodeValue('//*:response')
def json = new JsonSlurper().parseText(response)
log.info json.data.profile
log.info json.data.endpoints