Showing posts with label data. Show all posts
Showing posts with label data. Show all posts

Sunday, February 15, 2015

Reading data from single data source Single SQL Query for two charts in pentaho CDE

Hi guys...!!!

Community Dashboard Editor is the best reporting/dash boarding  tool that I have worked. Its smart functionality made me love to work with it and exploring the things time by time.

Youll learn how to fetch different columns from result set of a single query and use them in different analysis purpose in charting.

Recently I needed to work with a single query data source(SQL) of having 3 columns result set ...
Lets say there are 3 columns A,B and C where as A column is having some category names and B and C are having some columns.

A  B   C
--------------
abc 2   4
pqr  6   8 
xyz 10 5
and etc.

From the result set A&B are on first chart and A&C are on other chart..
Now how ?????? This question leads me to check the "Data sources" section of CDE.

Follow the steps below.

1) Click on the "sqloverjndi" which  you created for your SQL query.
2)  In the properties section you can find an option called "Output options". Just click on  it.
3) Lets say you have 3 columns in your result set and these 3 columns takes index values starting from 0 to n.. i.e., A column index is 0 , B column index is 1 and for the C  value 2 is the index.

  NOTE: if you have more numbers of columns you can give as many indexes by clicking "Add" button as many times.
4)For Chart 1:
  i) Click on the chart component where you want show A& B columns ( A is category B is value)
  ii) In the properties(Click on Advanced properties) click on "Pre Execution"
  iii) Write this below code
            function f() {
                                 this.chartDefinition.readers = [
                                 {names:category, indexes: 0},
                                  {names: value, indexes: 1},
                                    {indexs: 2}
                                    ];
             } 

  Why this {indexs:2} ? if you omit this the values of index2 append to the category names... to eliminate that problem you need to write it.

 5) For Chart2 :
 Repeat the steps in in point 4)
 Slight changes in code ...

function f() {
                                 this.chartDefinition.readers = [
                                 {names:category, indexes: 0},
                                  {names: value, indexes: 1},
                                    {indexs: 2}
                                    ];
             } 


You are done with reading data from single query of 3 columns where 1&2 for one chart and 1&3 for another chart...

Save your dashboard and see the preview.

Sadakar
BI developer 
( "Learning never exhausts the mind" )
Read more »

Saturday, January 31, 2015

PhoneGap Tutorial Parsing xml file using javascipt and displaying the data on the android and ios mobile screens

Title : I am going to explain u how to parse xml file and display data on your mobile screen.

Description : In todays world every business application need to contact webservices or xml services or xml files in the server and parse the files and need to display some results on the screen.for example take a live cricket score card : in the server we write a program where the score will be updated ball by ball,run by run in the web service , and the xml file also get updated with the live score and now the our application screen should also contact the webservice every 5 seconds and parse xml file and will update the live score for us , I will explain this with source code latter , for now i will explain you a simple example.

Here is the xml file which we are going to parse.



MakeMyTrip.com
MakeMyTrip.com is one of the good website providing Travel services to book oonline Flight,Hotel,Train and Bus tickets with guranteed lowest prices and provides new deals , offers and discount coupons every week and help you save money upto 20% while you travel.
travellogos/makemytrip-logo.jpg


GoIbibo.com
GoIbibo.com is one of the good website providing Travel services to book oonline Flight,Hotel,Train and Bus tickets with guranteed lowest prices and provides new deals , offers and discount coupons every week and help you save money upto 20% while you travel.
travellogos/goibibo_logo.png


Abhibus.com
Abhibus.com is one of the good website providing Travel services to book oonline Flight,Hotel,Train and Bus tickets with guranteed lowest prices and provides new deals , offers and discount coupons every week and help you save money upto 20% while you travel.
travellogos/abhibus-logo.png


Travelyaari.com
Travelyaari.com is one of the good website providing Travel services to book oonline Flight,Hotel,Train and Bus tickets with guranteed lowest prices and provides new deals , offers and discount coupons every week and help you save money upto 20% while you travel.
travellogos/travelyaari-com-logo-w240.png


Redbus.in
Redbus.com is one of the good website providing Travel services to book oonline Flight,Hotel,Train and Bus tickets with guranteed lowest prices and provides new deals , offers and discount coupons every week and help you save money upto 20% while you travel.
travellogos/logo_bc9228d_163.jpg


Expedia.co.in
Expedia.co.in is one of the good website providing Travel services to book oonline Flight,Hotel,Train and Bus tickets with guranteed lowest prices and provides new deals , offers and discount coupons every week and help you save money upto 20% while you travel.
travellogos/expedia-logo.png


Other websites
We Provide more websites that offer good Travel services to book oonline Flight,Hotel,Train and Bus tickets with guranteed lowest prices and provides new deals , offers and discount coupons every week and help you save money upto 20% while you travel.
travellogos/travel-agency-logos.jpg


Now we have to parse the above file using java script and display the results using html5. Here is the html and javascript code to parse this xml file.

Javascript file


function travel(){
if (window.XMLHttpRequest)
{ // code for IE7+, Firefox, Chrome, Opera, Safari
xmlhttp=new XMLHttpRequest();
}
else
{ // code for IE6, IE5
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp.open("GET","Travel.xml",false);
xmlhttp.send();
xmlDoc=xmlhttp.responseXML;
travels = xmlDoc.getElementsByTagName("website");
alert("travels:"+travels.length);
var websites = [];
var description = [];
var logos = [];
for(var travel=0;travel var websitename = travels[travel].getElementsByTagName("sitename")[0].childNodes[0].nodeValue;
websites.push(websitename);
var des = travels[travel].getElementsByTagName("Description")[0].childNodes[0].nodeValue;
description.push(des);
var images = travels[travel].getElementsByTagName("Image")[0].childNodes[0].nodeValue;
logos.push(images);
}
var listview = document.getElementById("container");
var ul = document.createElement("ul");
for(var i=0;i var livalue= document.createTextNode(websites[i]);
var desvalue = document.createTextNode(description[i]);
var li = document.createElement("li");

var table = document.createElement("table");
var table1 = document.createElement("table");
var tr1 = document.createElement("tr");
var td1 = document.createElement("td");
var img = new Image();
img.src= logos[i];
img.setAttribute("width",60);
img.setAttribute("height",30);
img.setAttribute(onclick, "test()");
td1.appendChild(img);
tr1.appendChild(td1);
var tr2 = document.createElement("tr");
var td2 = document.createElement("td");
var td3 = document.createElement("td");
td2.appendChild(livalue);
td3.appendChild(desvalue);
tr1.appendChild(td2);
tr2.appendChild(td3);
table.appendChild(tr1);
table1.appendChild(tr2);
li.appendChild(table);
li.appendChild(table1);
ul.appendChild(li);
}
listview.appendChild(ul);

}

Html File







Minimal AppLaud App











Coupons Shop












Read more »