Drill down in graph using FusionCharts Free for axis - fusioncharts

I have the following input xml file:
<Company >
<shareprice>
<timeStamp> 12:00:00.01</timeStamp>
<Price> 25.02</Price>
</shareprice>
<shareprice>
<timeStamp> 12:00:00.02</timeStamp>
<Price> 15</Price>
</shareprice>
<shareprice>
<timeStamp> 12:00:01.025</timeStamp>
<Price> 15.02</Price>
</shareprice>
<shareprice>
<timeStamp> 12:00:01.031</timeStamp>
<Price> 18.25</Price>
</shareprice>
<shareprice>
<timeStamp> 12:00:01.039</timeStamp>
<Price> 18.54</Price>
</shareprice>
<shareprice>
<timeStamp> 12:00:01.050</timeStamp>
<Price> 16.52</Price>
</shareprice>
<shareprice>
<timeStamp> 12:00:02.01</timeStamp>
<Price> 17.50</Price>
</shareprice>
<shareprice>
<timeStamp> 12:00:03.01</timeStamp>
<Price> 25.02</Price>
</shareprice>
<shareprice>
<timeStamp> 12:00:05.02</timeStamp>
<Price> 30</Price>
</shareprice>
<shareprice>
<timeStamp> 12:00:11.025</timeStamp>
<Price> 32.25</Price>
</shareprice>
<shareprice>
<timeStamp> 12:00:12.031</timeStamp>
<Price> 26.05</Price>
</shareprice>
<shareprice>
<timeStamp> 12:00:15.039</timeStamp>
<Price> 18.54</Price>
</shareprice>
<shareprice>
<timeStamp> 12:00:19.050</timeStamp>
<Price> 16.52</Price>
</shareprice>
<shareprice>
<timeStamp> 12:01:02.01</timeStamp>
<Price> 17.50</Price>
</shareprice>
</Company>
I carry out some analysis in R and produce two XML files. The first output file is in the format for a FusionChart Free Chart:
<graph caption="Share Data Wave" subcaption="For Person's Name" xAxisName="Time" yAxisMinValue="-0.025" yAxisName="Voltage" decimalPrecision="5" formatNumberScale="0" numberPrefix="" showNames="1" showValues="0" showAlternateHGridColor="1" AlternateHGridColor="ff5904" divLineColor="ff5904" divLineAlpha="20" alternateHGridAlpha="5">
<set name="2010-08-26 12:00:21.040" value="25.020000" hoverText = "The difference from last value: 0" ></set>
<set name="2010-08-26 12:01:02.531" value="15.000000" hoverText = "The difference from last value: -10.02" ></set>
<set name="2010-08-26 12:02:02.212" value="15.020000" hoverText = "The difference from last value: 0.0199999999999996" ></set>
<set name="2010-08-26 12:02:09.426" value="18.250000" hoverText = "The difference from last value: 3.23" ></set>
<set name="2010-08-26 12:02:20.364" value="18.540000" hoverText = "The difference from last value: 0.289999999999999" ></set>
<set name="2010-08-26 12:02:58.058" value="16.520000" hoverText = "The difference from last value: -2.02" ></set>
<set name="2010-08-26 12:03:10.262" value="17.500000" hoverText = "The difference from last value: 0.98" ></set>
<set name="2010-08-26 12:03:13.085" value="25.020000" hoverText = "The difference from last value: 7.52" ></set>
<set name="2010-08-26 12:04:07.601" value="30.000000" hoverText = "The difference from last value: 4.98" ></set>
<set name="2010-08-26 12:04:57.355" value="32.250000" hoverText = "The difference from last value: 2.25" ></set>
<set name="2010-08-26 12:05:07.259" value="26.050000" hoverText = "The difference from last value: -6.2" ></set>
<set name="2010-08-26 12:05:15.503" value="18.540000" hoverText = "The difference from last value: -7.51" ></set>
<set name="2010-08-26 12:06:06.538" value="16.520000" hoverText = "The difference from last value: -2.02" ></set>
<set name="2010-08-26 12:06:49.746" value="17.500000" hoverText = "The difference from last value: 0.98" ></set>
</graph>
My question is after seeing the full chart a user only wants to see data between times. In the above format it would be the name tag. How can I edit the xml file to show just the requested data points. Can this be done using a PHP form (or something similar)?

Yes, this is highly probable using PHP. If you wish to edit the XML as shown by you and retain some elements as per selected time range, please follow th steps:
Steps can be :
Use form elements to select the time range.
As per the range select the data that falls into the range using PHP XML parser
Generate FusionCharts specific XML
or
Use form elements to select the time range.
Parse the created FusionCharts specific XML to remove all the values of name attributes of set nodes which do not fall in the range
Use this final XML to generate chart.
I can put here a small PHP example for you so that you can use that.

Related

AIML Parser Example

I need some help to understand AIML templates using an example below, your help is appreciated to get this template working.
These are some of the sample inputs I am trying to handle and output I want to generate from AIML parsing.
Input : sale abc
Output : SALES ABC
Input : sales abc
Output : SALES ABC
Input : sale of product abc
Output : SALES ABC
Input : sale product abc
Output : SALES ABC
Input : What is the sale of product abc
Output : SALES ABC
Input : What is the average sale of product abc
Output : AVG SALES ABC
Input : What is the avg sale of product abc
Output : AVG SALES ABC
Input : What is the last 30 day average sale of product abc
Output : AVG SALES ABC 30
Input : What is the last 30 day avg sale of product abc
Output : AVG SALES ABC 30
I have been trying to start with something like this to begin with but this does not seem to progress well due to lack of clarity on this tool to me.
<category><pattern>
# <set>numbers</set> <set>days</set> <set>average</set> sales <set>prepositions</set> *</pattern>
<template>SALES <star index="1"/>,<star index="2"/>,<star index="3"/>,<star index="4"/>,<star index="5"/>,<star index="6"/> </template>
</category>
Where numbers set define > 1,2,3,4,5..... 100
Days set define > day, days
Average set define > average, avg , averages
Prepositions set define > of
Thanks!
You should do this with wildcards rather than sets. The only sets you need are for your products and possibly a set for the number of days.
This category is the response to your first 4 queries:
<category>
<pattern>SALE <set>products</set></pattern>
<template>
SALES <star/>
</template>
</category>
We can now use wildcards to <srai> to call the master category:
<category>
<pattern>SALES ^ <set>products</set> ^</pattern>
<template>
<srai>SALE <star index="2"/></srai>
</template>
</category>
<category>
<pattern>SALE ^ <set>products</set> ^</pattern>
<template>
<srai>SALE <star index="2"/></srai>
</template>
</category>
<category>
<pattern>WHAT IS THE SALE ^ <set>products</set> ^</pattern>
<template>
<srai>SALE <star index="2"/></srai>
</template>
</category>
This category handles your next 2 queries:
<category>
<pattern>WHAT IS ^ AVERAGE SALE ^ <set>products</set> ^</pattern>
<template>
AVG SALES <star index="3"/>
</template>
</category>
We can use this to say that AVG means AVERAGE. You could also put this in your normal.substitutions file.
<category>
<pattern>_ AVG *</pattern>
<template>
<srai><star/> average <star index="2"/></srai>
</template>
</category>
Finally, this category handles your last 2 queries.
<category>
<pattern>WHAT IS ^ LAST * DAY ^ AVERAGE SALE ^ <set>products</set> ^</pattern>
<template>
AVG SALES <star index="5"/> <star index="2"/>
</template>
</category>

how to change the timestamp format in other language PostgreSQL

PostgreSQL timestamp:
begin= '2018-06-07 08:29:49'
end = '2018-06-10 04:07:57'
QUERY:
select sa.\"end\"::timestamp(0) - sa.begin::timestamp(0)
from tabelle sa;
Output:
2 days 19:38:08
I would like to change this output "days" into "Tage", like:
2 Tage 19:38:08
Most important, when there is month different then it should display months in 'Monate', the same goes for years to 'Jahre'.
i tried to look about dateformat, but i need to change expr format not format like '%Y %m %d ...etc.
i tried this too:
to_char(extract(year from (sa."end"::timestamp - sa.begin::timestamp)),'00')||' Jahre '||to_char(extract(month from (sa."end"::timestamp - sa.begin::timestamp)),'00')||' Monate '||to_char(extract(day from (sa."end"::timestamp - sa.begin::timestamp)),'00')||' Tage '||to_char(extract(hour from (sa."end"::timestamp - sa.begin::timestamp)),'00')||':'||to_char(extract(minute from (sa."end"::timestamp - sa.begin::timestamp)),'00')||':'||to_char(extract(second from (sa."end"::timestamp - sa.begin::timestamp)),'00')
Output:
00 Jahre 00 Monate 02 Tage 19: 38: 08
it doesn't look good, cause month or year shall appear if there is number.
Important, only this 'day' needed to be changed in 'Tage' not setting character UFT8 or other things complete in german language!!!
Please i need your support.
There is some solution but in other way:
select extract(day from (sa.\"end\"::timestamp - sa.begin::timestamp))||' Tage '||
to_char(extract(hour from (sa.\"end\"::timestamp-sa.begin::timestamp)),'00')||':'||
to_char(extract(minute from (sa.\"end\"::timestamp - sa.begin::timestamp)),'00')||':'||
to_char(extract(second from (sa.\"end\"::timestamp - sa.begin::timestamp)),'00')
from tabelle sa
Output:
2 Tage 19: 38: 08

transforming date from xml to csv using dataweave

I want to transform a date which is attribute coming from xml file into csv format using dataweave. now, transformation rule is 'If date is Sunday, make the date minus 6 days'. otherwise keep as it is.
If your input is something like this -
<?xml version='1.0' encoding='UTF-8'?>
<root>
<createDate>2016-05-08</createDate>
</root>
Then you can use below dataweave code to get date as required. When the day is Sunday, subtract 6 days from date -
%dw 1.0
%output application/csv
---
{
row: {
date: (payload.root.createDate as :date) unless
(((payload.root.createDate as :date) as :string {format: "E"}) == 'Sun')
otherwise ((payload.root.createDate as :date) - |P6D|)
}
}
It will output as below -
date
2016-05-02

Retrieving date from database in jaser

I have date as datetime in mysql. But when I am retriving value in jasper I am getting null pointer.
net.sf.jasperreports.engine.JRException: Error retrieving field value from bean : new java.text.SimpleDateFormat("YYYY-MM-DD HH:MI:SS").format($F{birthDate})
<field name="birthDate" class="java.util.Date">
<fieldDescription>
<![CDATA[new java.text.SimpleDateFormat("YYYY-MM-DD HH:MI:SS").format($F{birthDate})]]>
</fieldDescription>
</field>
Please help me how do I get the correct date.
According to documentation there are no MI pattern in «Date and Time Patterns». So, if you want to define the minutes then you must use m or mm patern. Also you must use y patern for year, d or dd patern to define the days in month. And use s or ss for seconds, because S is for milliseconds:
new java.text.SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format($F{birthDate})

XSL Transform extracting min and max dates

I'm trying to extract min and max dates from an XML source. I'm getting a nodeset into my variables and I need the actual date value within the nodes and can't find how to get it.
Source XML:
<Info dataSource="source">
<Detail>
<StartDate>20121211</StartDate>
<EndDate>20130112</EndDate>
</Detail>
<Detail>
<StartDate>20121211</StartDate>
<EndDate>20130112</EndDate>
</Detail>
<Detail>
<StartDate>20121211</StartDate>
<EndDate>20130112</EndDate>
</Detail>
<Detail>
<StartDate>20121218</StartDate>
<EndDate>20130114</EndDate>
</Detail>
</Info>
The XSL code:
<xsl:if test="//StartDate != '' and //EndDate != ''">
<xsl:variable name ="startDate">
<xsl:for-each select="//StartDate">
<xsl:sort select="StartDate" data-type="text" order="ascending"/>
<xsl:if test="position() = 1">
<xsl:value-of select="." />
</xsl:if>
</xsl:for-each>
</xsl:variable>
<xsl:variable name ="endDate">
<xsl:for-each select="//EndDate">
<xsl:sort select="EndDate" data-type="text" order="descending"/>
<xsl:if test="position() = 1">
<xsl:value-of select="." />
</xsl:if>
</xsl:for-each>
</xsl:variable>
</xsl:if>
The dates are formatted correctly to support the sorts and retrieval, the issue is once the variables are populated I can't find how to access their values:
If you're using XSLT 2.0 you have min and max functions which do the work for you. XSLT 1.0 doesn't have these functions, but you can cheat by doing this (may be rather inefficient for large inputs, but it works):
<xsl:variable name="startDate" select="string(//StartDate[not(. > //StartDate)])" />
and similarly for the endDate. The trick here is that you're looking for the StartDate d for which there is no other StartDate that d is greater than.