Showing posts with label any. Show all posts
Showing posts with label any. Show all posts

Wednesday, February 18, 2015

Java program to display multiplication table of any number

Java program to display multiplication table of any number

class Table
{
public static void main(String...s)
{
int n,i;
n=Integer.parseInt(s[0]);

for(i=1;i<=10;++i)
System.out.println(n+" * "+i+" = "+(n*i));
}
}
Read more »

Saturday, February 14, 2015

C program to find factorial of any number using recursion

C program to find factorial of any number using recursion

#include<stdio.h>
#include<conio.h>

void main()
{
int fac,n;
int factorial(int);
clrscr();

printf("Enter any number:");
scanf("%d",&n);

fac=factorial(n);
printf("Factorial=%d",fac);
getch();
}

int factorial(int x)
{
int f;
if(x==1||x==0)
return 1;
else
f=x*factorial(x-1);

return f;
}
Read more »

Friday, February 13, 2015

Any chart responsive code in PreExecution in Pntaho CDE



function f(){
var myself = this;
  // Set initial width to match the placeholder
  myself.chartDefinition.width = myself.placeholder().width();

  // Attach the resize handler only on the first execution of the chart component
  if (!this.resizeHandlerAttached){

    // Ensure render is only triggered after resize events have stopped
    var debouncedResize = _.debounce(function(){

      // Show chart again.
      myself.placeholder().children().css(visibility,visible);

      // Change chart width
      myself.chartDefinition.width = myself.placeholder().width();
      myself.render( myself.query.lastResults() );
    }, 200);

    // Attach resize handler
    $(window).resize(function(){

      // Only trigger resize if the container has changed width
      if ( myself.chartDefinition.width != myself.placeholder().width()){

        // Temporarily hide chart so that overflow does not happen
        myself.placeholder().children().css(visibility,hidden);

        // Trigger the resize with debounce
        debouncedResize();
      }    
    });

    this.resizeHandlerAttached = true;
  }
  
}
Read more »

Thursday, February 12, 2015

Drill down from one dashboard to another dashboard in Pentaho CDE Simple Example Not included any parameters

Hi Guys,

This post will teach you how you can drill down from one dashboard to another dashboard in pentaho CDE. This workout has done by one of my colleagues who is a fast learner.

You need to focus on 2 things in this post:
1) Connecting to JDBC datasource
2) Drill down from one dashboard to another dashboard.

NOTE :
Ill update you in next post about drill down from one dashboard to another dashboard using custom parameters concept.(Next work out).

Versions & Tools used for this post:
Pentaho C-Tools(CDE,CDA,CDF) 13.09 stable.
PostgreSQL DB - (foodmart database - which is one of  jasperserver default databases)
Pentaho BA server 4.8 stable.

SOURCE CODE OF THE EXAMPLE
Download the example using below link
https://drive.google.com/file/d/0BymV_QP4TGBEZ0p1cnpydDJGeDQ/edit?usp=sharing

Deployment procedure:
1) Down load the .rar file from the link(File-Download in the google drive)
2) Unzip it and place it in "pentaho-solutions" folder.
3) Refresh or clear the cache of the pentaho browser(find upper left - Browser)
4) If you are unable to find the folder name , you need to create an index.xml file (Eg: you can find it inside any folder. copy and paste it inside your working folder and change the name of it).
5) No need to restart the pentaho server.
NOTE: Edit data base connections as per your requirement also you may need to change the query if you use any other database than foodmart

Dashboard 1:
1) Layout section
* Design your lay out for dashboard1
2) Components section
* You will be placing 1 bar chart where you will click on bars for drilling down to another dashboard.
We will come back to this section again after designing Dashboard 1 and Dashboard 2
3) Data Sources section
* Click on Data source Icon on right top conrner.
* From the left .. click on SQL queries -> Click on sql over sqljdbc
* Give the name and all the properties as shown in below image.

NOTE:
PostgreSQL server default details :
Driver: org.postgresql.Driver
UserName : postgres
Password : postgres
URL:  jdbc:postgresql://localhost:6062/foodmart where 6062 is the port number which I used for postgres and foodmart is the database.
Note that default port number for postgresSQL is 5432 .

* Write a query which will suits for bars in the chart
* For eg:
SELECT
    c.country,
    c.state_province ,
    c.city,
    SUM(sf.store_sales)

FROM
    customer c,
    sales_fact_1997 sf
WHERE  c.customer_id=sf.customer_id
GROUP BY
    c.country,
    c.state_province,
    c.city

ORDER BY
c.country,c.state_province,c.city



* See the preview of the dashboard
* Out put will looks like below.

Dashboard 2 :
* Repeat the same steps as followed in Dashboard 1
* Take any component to display on the second dashboard.
* I have taken table component in this example and  the output will looks like below mentioned image.
*


We have done with 2 dashboards individually.
Now, Its the time for us to some trick on Dashboard 1 so that when we click on Dashboard 1 , it will have to take you to Dashboard2

Steps:
1) Lets go back to Dashboard 1
2) Go to the Chart component and in the properties give clickable as True
3) In the clickAction you need to give the URL of second dashboard in java script.
Eg:
function q(s,c,v)
{

window.location = http://localhost:8085/pentaho/content/pentaho-cdf-dd/Render?solution=CDE-+Exploring&path=%2FDevelopement%2FDashboard+Drill+down&file=drill_down_to_table.wcdf;

}


Thats it you have done with drill down. Save the dashboard 1 and see the preview and then click on any bar appearing , you will navigate to the 2nd dashboard.

NOTE :
This post is only giving the idea of how to drill down from one dash board to another dashboard.
This post doesnt work with any parameters. The use custom parameter with drill down from 1 dashboard to another dashboard will come in next post from my end.


URL generating problem / Path problem for Second Dashboard

How to generate the URL for 2nd dashboard ( not only for this but also works for every dashboard).?

* Right click on 2nd Dashboard and click on "Open In New Tab" the with the URL the 2nd dashboard will open in fresh tab.
* Copy that URL and paste in drill down function.
* For eg : Just reference : Find the images below
 





References :
1) http://forums.pentaho.com/showthread.php?152634-Drill-down-from-bar-chart-to-another-dashboard

2) http://forums.pentaho.com/showthread.php?82999-Drill-Down-in-DashBoards

Sadakar
("Learning never exhausts the mind")




Read more »