Forum Replies Created by munmun

Viewing 7 posts - 1 through 7 (of 7 total)
  • In this “Please take a look at this Sample Project.” as mentioned by you earlier , if I provide a string/date value in the code : a blank screen with no data comes . Data only in double format is picking up to render the chart which is not proper.
    String sql = ” SELECT * from Fan2TempMotorBearing where rownum < 50 order by datetime”;
    Statement stmt = conn.createStatement();
    ResultSet rset = stmt.executeQuery(sql);

    while (rset.next()) {
    Date xVal =rset.getDate(“datetime”);// Date values
    double y1Val = (double)rset.getDouble(“y_actual”), y2Val = (double)rset.getDouble(“y_predicted”);

    map = new HashMap<Object,Object>(); map.put(“x”, xVal); map.put(“y”, y1Val); list1.add(map);
    dataPoints1 = gsonObj.toJson(list1);

    map = new HashMap<Object,Object>(); map.put(“x”, xVal); map.put(“y”, y2Val); list2.add(map);
    dataPoints2 = gsonObj.toJson(list2);
    }
    }

    Query:
    create table Fan2TempMotorBearing (datetime date , y_actual float(50), y_predicted float(50))
    insert into Fan2TempMotorBearing values (TO_DATE(‘2018-07-01 00-00-00′,’yyyy-mm-dd hh24-mi-ss’),’50.183′,’53.0519169458035′)
    insert into Fan2TempMotorBearing values (TO_DATE(‘2018-07-01 00-05-00′,’yyyy-mm-dd hh24-mi-ss’),’50.183′,’53.0261445540871′)

    kindly check for this if possible why only double parameters can plot the graph from database and not string / date type data.

    dear indranil

    Do you have a sample project with datetime picker attached to it. I have checked this sample but the issue is that it fetches data only for double values. if my x axis has string values or datetime values it does not produce the required output but gives a blank screen.

    in reply to: create multiseries chart #26038

    This is not giving the desired output.

    in reply to: create multiseries chart #26037

    I have mailed you already with my issue Manoj. Was not able to post the code here so pasted in jsfiddle.

    <%@ page import="java.util.*" %>
    <%@ page import="java.sql.*" %>
    <%@ page import="java.math.*" %>
    <%@ page import="com.google.gson.Gson"%>
    	
    <%
    Gson gsonObj = new Gson();
    Map<Object,Object> map = null;
    List<Map<Object,Object>> list1 = new ArrayList<Map<Object,Object>>(), list2 = new ArrayList<Map<Object,Object>>();
    String dataPoints1 = null, dataPoints2 = null;
    
    /* https://www.tutorialspoint.com/jdbc/jdbc-db-connections */
    try {
       Class.forName("oracle.jdbc.driver.OracleDriver").newInstance();   
    }
    catch(Exception ex) {
       System.out.println("Error!");
       System.exit(1);
    }
    
    String url = "jdbc:oracle:thin:@localhost:1521:xe";
    String user = "SYS as SYSDBA";
    String PASS = "SYS";
    Connection conn = DriverManager.getConnection(url, user, PASS);
    
    
    PreparedStatement pstmt = null;
    try {
    	String sql = "select * from shv order by datetime ";
    	Statement stmt = conn.createStatement();
    	ResultSet rset = stmt.executeQuery(sql);
    	
    	while (rset.next()) {
        String xVal = rset.getString("datetime"); 
    	String y1Val = (String)rset.getString("y_actual");
    	String y2Val = rset.getString("y_predicted");
    		
    		map = new HashMap<Object,Object>(); 
    		map.put("x", xVal); 
    		map.put("y", y1Val); 
    		list1.add(map);
    		dataPoints1 = gsonObj.toJson(list1);
    		//Date dt=new Date(dataPoints1);
    	
    		
    		map = new HashMap<Object,Object>(); map.put("x", xVal); map.put("y", y2Val); list2.add(map);
    		dataPoints2 = gsonObj.toJson(list2);
    	}
    }
    catch (SQLException e) {
       System.out.println(e);
    }
    
    %>
    
    <!DOCTYPE HTML>
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <script src="https://cdn.canvasjs.com/canvasjs.min.js"></script>
    <script type="text/javascript">
    window.onload = function(){
    	var chart = new CanvasJS.Chart("chartContainer", {
    		theme: "light2",
    		animationEnabled: true,
    		title: {
    			text: "Multiseries line Chart with Data from Oracle Database"
    		},
    		
    		data: [{
    			type: "line", //change type to bar, line, area, pie, etc
    			dataPoints: <%out.print(dataPoints1);%>
    		},{
    			type: "line", //change type to bar, line, area, pie, etc
    			dataPoints: <%out.print(dataPoints2);%>
    		}]
    	});
    	chart.render();
    	
    	function toogleDataSeries(e){
    		if (typeof(e.dataSeries.visible) === "undefined" || e.dataSeries.visible) {
    			e.dataSeries.visible = false;
    		} else{
    			e.dataSeries.visible = true;
    		}
    		chart.render();
    	}
    }
    </script>
    	
    </head>
    <body>
    	<div id="chartContainer" style="width: 100%; height: 400px"></div>	
    </body>
    </html> 
    in reply to: create multiseries chart #25943

    https://jsfiddle.net/munmunpanda/82Luwp9z/3/

    This is a jsfiddle link where in html i have placed my entire code and in javascript section i have placed the queries that i m running currently.

    As per your instructions i ran the sample project but got a blank screen . kindly reply soon.

    in reply to: create multiseries chart #25940

    hi manoj

    in reply to: create multiseries chart #25902

    i want to create using java by using hashmap or arraylist a multiseries chart from data from database . oracle database.

Viewing 7 posts - 1 through 7 (of 7 total)