Commit 3ef04975 authored by nsawalakhe's avatar nsawalakhe

Added New Functionality for Gauge Chart.

Added New file AquaGauge.js and GaugeChartBuilder.java.
Modified MetaDataDtl.java,GraphComponent.java,BuildChart.js and GwtDashboardPage.html.


git-svn-id: http://15.206.35.175/svn/proteus/business-java/trunk@36776 ce508802-f39f-4f6c-b175-0d175dae99d5
parent 03696c3f
package ibase.client;
import java.util.ArrayList;
import java.util.LinkedHashMap;
import com.google.gwt.json.client.JSONObject;
import com.google.gwt.json.client.JSONParser;
import com.google.gwt.json.client.JSONString;
import com.google.gwt.json.client.JSONValue;
import com.google.gwt.user.client.Window;
public class GaugeChartBuilder
{
public JSONObject buildGaugeChart(ArrayList<ArrayList<String>> graphDtlList, JSONObject jsonObjGraph, String dataSource)
{
JSONObject jsonObjFrGraph = (JSONObject) jsonObjGraph.get(dataSource);
JSONObject fetchRowWiseVal = null;
JSONObject graphJson = new JSONObject();
LinkedHashMap<JSONValue, JSONValue> barMap = null;
String propertyVal = "";
ArrayList<LinkedHashMap<JSONValue, JSONValue>> allDataList = new ArrayList<LinkedHashMap<JSONValue, JSONValue>>();
ArrayList<String> dataList = null;
String data = "";
barMap = new LinkedHashMap<JSONValue, JSONValue>();
for (int jsnCnt = 0; jsnCnt < graphDtlList.size(); jsnCnt++)
{
propertyVal = "" + graphDtlList.get(jsnCnt);
if (jsnCnt == 0)
{
barMap.put(new JSONString("componentTitle"), new JSONString(propertyVal));
}
if (jsnCnt == 1)
{
barMap.put(new JSONString("componentCss"), new JSONString(propertyVal));
}
if (jsnCnt == 2)
{
barMap.put(new JSONString("componentIcon"), new JSONString(propertyVal));
}
if (jsnCnt == 3)
{
barMap.put(new JSONString("height"), new JSONString(propertyVal));
}
if (jsnCnt == 4)
{
barMap.put(new JSONString("width"), new JSONString(propertyVal));
}
if (jsnCnt == 5)
{
barMap.put(new JSONString("caption"), new JSONString(propertyVal));
}
if (jsnCnt == 6)
{
barMap.put(new JSONString("sub_caption"), new JSONString(propertyVal));
}
if (jsnCnt == 7)
{
barMap.put(new JSONString("bg_color"), new JSONString(propertyVal));
}
if (jsnCnt == 8)
{
barMap.put(new JSONString("minValue"), new JSONString(propertyVal));
}
if (jsnCnt == 9)
{
barMap.put(new JSONString("maxValue"), new JSONString(propertyVal));
}
if (jsnCnt == 10)
{
barMap.put(new JSONString("noOfDivisions"), new JSONString(propertyVal));
}
if (jsnCnt == 11)
{
barMap.put(new JSONString("noOfSubDivisions"), new JSONString(propertyVal));
}
if (jsnCnt == 12)
{
barMap.put(new JSONString("showMinorScaleValue"), new JSONString(propertyVal));
}
if (jsnCnt == 13)
{
barMap.put(new JSONString("pointerColor"), new JSONString(propertyVal));
}
}
allDataList.add(barMap);
graphJson.put("metaData", JSONParser.parseStrict(allDataList.toString().replace('=', ':')));
allDataList = new ArrayList<LinkedHashMap<JSONValue, JSONValue>>();
barMap = new LinkedHashMap<JSONValue, JSONValue>();
dataList=graphDtlList.get(graphDtlList.size()-1);
for (int jsnCnt = 0; jsnCnt < jsonObjFrGraph.size(); jsnCnt++)
{
barMap = new LinkedHashMap<JSONValue, JSONValue>();
fetchRowWiseVal = (JSONObject) jsonObjFrGraph.get(String.valueOf(jsnCnt));
for (String idName : dataList)
{
data = fetchRowWiseVal.get(idName).toString().replace('"', ' ');
if (data.trim().length() != 0)
{
barMap.put(new JSONString(idName), fetchRowWiseVal.get(idName));
}
}
allDataList.add(barMap);
}
/*barMap.put(new JSONString("refresh"),new JSONString("70"));
allDataList.add(barMap);
*/
graphJson.put("data", JSONParser.parseStrict(allDataList.toString().replace('=', ':')));
return graphJson;
}
}
...@@ -598,6 +598,41 @@ public class GraphComponent extends Composite ...@@ -598,6 +598,41 @@ public class GraphComponent extends Composite
} }
/** End Star Code for Building ganttChart by sachin 5 Aug 2015 **/ /** End Star Code for Building ganttChart by sachin 5 Aug 2015 **/
/** Star Code for Building HTML_GAUGE by sachin 5 Aug 2015 **/
if ("HTML_GAUGE".equalsIgnoreCase(type))
{
for (String graphNo : graphDataMap.keySet())
{
graphDtlList = graphDataMap.get(graphNo);
for (int i = 0; i < graphDtlList.size(); i++)
{
if (i == 0)
{
gridComponantTitleName = (String) graphDtlList.get(i);
}
if (i == 1)
{
gridCssName = (String) graphDtlList.get(i);
}
}
graphJson = new GaugeChartBuilder().buildGaugeChart(graphDtlList, jsonObjFrGraph, dtSrouce);
if (graphJson.size() == 0)
{
graphJson.put("chart", new JSONString(""));
}
if (graphJson != null && graphJson.size() > 0)
{
this.createOuterDiv("Gauge"+componentId, type, gridCssName);
this.createGaugeChart(graphJson.toString(), "Gauge" + componentId + "Div");
}
}
}
/** End Star Code for Building HTML_GAUGE by sachin 5 Aug 2015 **/
...@@ -613,6 +648,19 @@ public class GraphComponent extends Composite ...@@ -613,6 +648,19 @@ public class GraphComponent extends Composite
} }
/** Added new Method by sachin on 18 Aug 2015 **/
private native void createGaugeChart(String chartData, String chartContainer)
/*-{
try {
$wnd.createGaugeChart(chartData, chartContainer);
} catch (e) {
alert("Excpeiton :: GraphComponent : createGnttCht [" + e.message
+ "]");
}
}-*/;
/**End Added new Method by sachin on 28 Aug 2015 **/
/*added new method for smart filter by sachin 12 may 2015*/ /*added new method for smart filter by sachin 12 may 2015*/
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
......
...@@ -1624,6 +1624,29 @@ public class MetaDataDtl ...@@ -1624,6 +1624,29 @@ public class MetaDataDtl
} }
//*** End Start Code for Gantt Chart (Added by sachin on 4-8-15)*****\\ //*** End Start Code for Gantt Chart (Added by sachin on 4-8-15)*****\\
//***Start Code for HTML Gauge Chart (Added by sachin on 18-08-15)*****\\
if ("component".equals(viewNode.getNodeName()) && type.equalsIgnoreCase("HTML_GAUGE"))
{
graphMeataDataMap = new HashMap<String, ArrayList<Object>>();
typeGraphMap = new LinkedHashMap<String, String>();
graphDataSourceMap = new LinkedHashMap<String, String>();
graphID = viewNode.getAttributes().getNamedItem("id").getNodeValue();
type = viewNode.getAttributes().getNamedItem("type").getNodeValue();
dataSource = viewNode.getAttributes().getNamedItem("datasource").getNodeValue();
graphDataSourceMap.put("datasource" + graphID, dataSource);
typeGraphMap.put("type" + graphID, type);
graphNodeList = viewNode.getChildNodes();
conuter++;
gridNGraphMeataDataMap.put("type" + graphID, typeGraphMap);
graphMeataDataMap.put("graph" + conuter, this.getGaugeChrtList(graphNodeList));
gridNGraphMeataDataMap.put(graphID, graphMeataDataMap);
gridNGraphMeataDataMap.put("datasource" + graphID, graphDataSourceMap);
}
//*** End Start Code for HTML Gauge Chart (Added by sachin on 18-08-15)*****\\
} }
} }
} }
...@@ -1983,4 +2006,136 @@ public class MetaDataDtl ...@@ -1983,4 +2006,136 @@ public class MetaDataDtl
} }
/* End Added New Method By sachin on 12 Aug 15 */ /* End Added New Method By sachin on 12 Aug 15 */
/* Added New Method By sachin For Gauge Cahrt on 18 Aug 15 */
private ArrayList<Object> getGaugeChrtList(NodeList graphNodeList)
{
ArrayList<String> dataList = new ArrayList<String>();
ArrayList<Object> graphDtlList = new ArrayList<Object>();
NodeList groupFilterNodeList = null;
NodeList columNodeList = null;
Node groupFilterNode = null;
Node graphDataNode = null;
String componentTitle = "";
String componentIcon = "";
String childNodeName = "";
String componentCss = "";
Node columnNode = null;
String data = "";
String height = "";
String width = "";
String caption = "";
String bgColor = "";
String subCaption = "";
String minValue = "";
String maxValue = "";
String noOfDiv = "";
String noOfSubDiv = "";
String minorSclValue = "";
String pointrColor = "";
for (int i = 0; i < graphNodeList.getLength(); i++)
{
graphDataNode = graphNodeList.item(i);
childNodeName = graphDataNode.getNodeName();
if ("componenttitle".equalsIgnoreCase(childNodeName))
{
componentTitle = graphDataNode.getChildNodes().item(0).getNodeValue();
}
if ("component_css".equalsIgnoreCase(childNodeName))
{
componentCss = graphDataNode.getChildNodes().item(0).getNodeValue();
}
if ("component_icon".equalsIgnoreCase(childNodeName))
{
componentIcon = graphDataNode.getChildNodes().item(0).getNodeValue();
}
if ("chart_properties".equalsIgnoreCase(childNodeName))
{
groupFilterNodeList = graphDataNode.getChildNodes();
for (int j = 0; j < groupFilterNodeList.getLength(); j++)
{
groupFilterNode = groupFilterNodeList.item(j);
if ("height".equalsIgnoreCase(groupFilterNode.getNodeName()))
{
height = groupFilterNode.getChildNodes().item(0).getNodeValue();
}
if ("width".equalsIgnoreCase(groupFilterNode.getNodeName()))
{
width = groupFilterNode.getChildNodes().item(0).getNodeValue();
}
if ("caption".equalsIgnoreCase(groupFilterNode.getNodeName()))
{
caption = groupFilterNode.getChildNodes().item(0).getNodeValue();
}
if ("sub_caption".equalsIgnoreCase(groupFilterNode.getNodeName()))
{
subCaption = groupFilterNode.getChildNodes().item(0).getNodeValue();
}
if ("bg_color".equalsIgnoreCase(groupFilterNode.getNodeName()))
{
bgColor = groupFilterNode.getChildNodes().item(0).getNodeValue();
}
if ("minvalue".equalsIgnoreCase(groupFilterNode.getNodeName()))
{
minValue = groupFilterNode.getChildNodes().item(0).getNodeValue();
}
if ("maxvalue".equalsIgnoreCase(groupFilterNode.getNodeName()))
{
maxValue = groupFilterNode.getChildNodes().item(0).getNodeValue();
}
if ("noofdivisions".equalsIgnoreCase(groupFilterNode.getNodeName()))
{
noOfDiv = groupFilterNode.getChildNodes().item(0).getNodeValue();
}
if ("noofsubdivisions".equalsIgnoreCase(groupFilterNode.getNodeName()))
{
noOfSubDiv = groupFilterNode.getChildNodes().item(0).getNodeValue();
}
if ("showminorscalevalue".equalsIgnoreCase(groupFilterNode.getNodeName()))
{
minorSclValue = groupFilterNode.getChildNodes().item(0).getNodeValue();
}
if ("pointercolor".equalsIgnoreCase(groupFilterNode.getNodeName()))
{
pointrColor = groupFilterNode.getChildNodes().item(0).getNodeValue();
}
}
}
if ("column_group".equalsIgnoreCase(childNodeName))
{
groupFilterNodeList = graphDataNode.getChildNodes();
for (int j = 0; j < groupFilterNodeList.getLength(); j++)
{
groupFilterNode = groupFilterNodeList.item(j);
columNodeList = groupFilterNode.getChildNodes();
for (int k = 0; k < columNodeList.getLength(); k++)
{
columnNode = columNodeList.item(k);
data = columnNode.getAttributes().getNamedItem("id").getNodeValue();
dataList.add(data);
}
}
}
}
graphDtlList.add(componentTitle);
graphDtlList.add(componentCss);
graphDtlList.add(componentIcon);
graphDtlList.add(height);
graphDtlList.add(width);
graphDtlList.add(caption);
graphDtlList.add(subCaption);
graphDtlList.add(bgColor);
graphDtlList.add(minValue);
graphDtlList.add(maxValue);
graphDtlList.add(noOfDiv);
graphDtlList.add(noOfSubDiv);
graphDtlList.add(minorSclValue);
graphDtlList.add(pointrColor);
graphDtlList.add(dataList);
return graphDtlList;
}
/* End Added New Method By sachin For Gauge Cahrt on 18 Aug 15 */
} }
This diff is collapsed.
...@@ -497,3 +497,49 @@ function show_scale_options(mode){/* ...@@ -497,3 +497,49 @@ function show_scale_options(mode){/*
{ id:8, source:8, target:9, type:"2"}, { id:8, source:8, target:9, type:"2"},
] ]
};*/ };*/
/* Start Added function createGaugeChart by sachin for Gauge Chart on 28 Aug 15 */
function createGaugeChart(jsonObj, chartContainer, height, width) {
//alert("jsonObj is =" + jsonObj);
var parsedData = JSON.parse(jsonObj);
var innerDiv = document.createElement('canvas');
innerDiv.id = "canvasDiv"
innerDiv.width = parsedData.metaData[0].width;
innerDiv.height = parsedData.metaData[0].height;
document.getElementById(chartContainer).appendChild(innerDiv);
var aGauge = aGauge = new AquaGauge('canvasDiv');
aGauge.props.minValue = parsedData.metaData[0].minValue;
aGauge.props.maxvalue = parsedData.metaData[0].maxValue;
aGauge.props.noofdivisions = parsedData.metaData[0].noOfDivisions;
aGauge.props.noOfSubDivisions = parsedData.metaData[0].noOfSubDivisions;
aGauge.props.showMinorScaleValue = parsedData.metaData[0].showMinorScaleValue;
aGauge.props.dialSubTitle = parsedData.metaData[0].sub_caption;
aGauge.props.dialTitle = parsedData.metaData[0].caption;
var pointrColor = parsedData.metaData[0].pointerColor;
if (pointrColor != undefined && pointrColor.trim().length > 0)
{
aGauge.props.pointerColor = pointrColor;
}
var bgColor = parsedData.metaData[0].bg_color;
if (bgColor != undefined && bgColor.trim().length > 0)
{
aGauge.props.backgroundColor = bgColor;
}
//alert("parsedData.data[0].refresh ="+parsedData.data[0].refresh);
aGauge.refresh(parsedData.data[0].refresh);
}
/* End Added function createGaugeChart by sachin for Gauge Chart on 28 Aug 15 */
...@@ -19,6 +19,11 @@ ...@@ -19,6 +19,11 @@
<!-- End-Imports new Css And Script For gantt Chart by sachin on 05-Aug-15 --> <!-- End-Imports new Css And Script For gantt Chart by sachin on 05-Aug-15 -->
<!--Start-Imports new Css And Script For gauge Chart by sachin on 28-Aug-15 -->
<script src="FusionChart/js/AquaGauge.js" type="text/javascript"></script>
<!-- <script src="FusionChart/js/helper.js" type="text/javascript"></script> -->
<!-- End-Imports new Css And Script For gauge Chart by sachin on 28-Aug-15 -->
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment