Page 1 of 1

Chart Xml with get('D_X_X')

Posted: Wed Jan 17, 2018 11:15 am
by Tracker
Hi,
I would like to make a dynamic chart bind with "chart xml" property and screen element value for example

Code: Select all

<chart caption='Graphe' numberprefix='$' plotgradientcolor='' bgcolor='FFFFFF' showalternatehgridcolor='0' showplotborder='0' divlinecolor='CCCCCC' showvalues='1' showcanvasborder='0' canvasbordercolor='CCCCCC' canvasborderthickness='1' yaxismaxvalue='30000' captionpadding='30' linethickness='3' sshowanchors='0' yaxisvaluespadding='15' showlegend='1' use3dlighting='0' showshadow='0' legendshadow='0' legendborderalpha='0' showborder='0' palettecolors='#EED17F,#97CBE7,#074868,#B0D67A,#2C560A,#DD9D82'>
<set label='Online Ads' value='125000' issliced='1' />
<set label='Print Ads' value='110000' />
<set label='Content Marketing' value='" + get("D_5_63") + "'" />
<set label='Tradeshows' value='" + get("D_3_63") + "'" />
</chart>
.
ButI have a 'No data to display' message.

Re: Chart Xml with get('D_X_X')

Posted: Wed Jan 17, 2018 11:43 am
by Scott Klement
I'm assuming this is just a snippet from a larger piece of code, because it makes absolutely no sense by itself.

Can you give me more information about this? How are you coding it? How are you applying the property?

Re: Chart Xml with get('D_X_X')

Posted: Wed Jan 17, 2018 12:25 pm
by Tracker
I would like to implement chart widget like picture widget.png ; and this is a sample of code of xml I use to bind the widget. the last picture shows data on the screen that I use to make the chart

Re: Chart Xml with get('D_X_X')

Posted: Wed Jan 17, 2018 1:17 pm
by Tracker
this is the picture I get

Re: Chart Xml with get('D_X_X')

Posted: Wed Jan 17, 2018 3:43 pm
by Scott Klement
You've coded part of your data as XML data (which is what the property is expecting) but then you've coded part of it as JavaScript. The property doesn't know that it's JavaScript -- it's expecting XML. So it will try to treat it as XML, which of course won't be valid.

Re: Chart Xml with get('D_X_X')

Posted: Wed Jan 17, 2018 3:54 pm
by Scott Klement
In order for a property to be run as JavaScript code, it needs to start with "script:" or "js:". But, your code isn't valid JavaScript... to make it valid JavaScript, you need to put the whole XML document inside quotes and remove the extra line feeds from the middle.

The result would look like this:

Code: Select all

script: "<chart caption='Graphe' numberprefix='$' plotgradientcolor='' bgcolor='FFFFFF' showalternatehgridcolor='0' showplotborder='0' divlinecolor='CCCCCC' showvalues='1' showcanvasborder='0' canvasbordercolor='CCCCCC' canvasborderthickness='1' yaxismaxvalue='30000' captionpadding='30' linethickness='3' sshowanchors='0' yaxisvaluespadding='15' showlegend='1' use3dlighting='0' showshadow='0' legendshadow='0' legendborderalpha='0' showborder='0' palettecolors='#EED17F,#97CBE7,#074868,#B0D67A,#2C560A,#DD9D82'><set label='Online Ads' value='125000' issliced='1' /><set label='Print Ads' value='110000' /><set label='Content Marketing' value='" + get("D_5_63") + "' /><set label='Tradeshows' value='" + get("D_3_63") + "' /></chart>"
Notice that:

1) It now starts with "script:" so JavaScript will be expected.
2) The remainder of the data is now a valid JavaScript string expression.
3) Quotes are provided at the start/end of each string to be concatenated.
4) line feeds are removed