Package org.jsflot.xydata

Examples of org.jsflot.xydata.XYDataPoint


    @Ignore
    public void test_that_XYDataCollection_returns_correct_json() throws JSONException {
        XYDataSetCollection xyCollection = new XYDataSetCollection();
        XYDataList xyList = new XYDataList();
        xyList.setLabel("Set1");
        xyList.addDataPoint(new XYDataPoint(1, 1));
        xyList.addDataPoint(new XYDataPoint(2, 2));
        xyList.addDataPoint(new XYDataPoint(3, 3));
        xyList.addDataPoint(new XYDataPoint(5, 5));
        xyCollection.addDataList(xyList);

        StringBuilder expected = new StringBuilder();
        expected.append("{\"chart\": [ {\"label\": \"Set1\", \"data\": [[1,1], [2,2], [3,3], [5,5]]}],\"instrumentationNode\":\"chartId\"}");
        String jsonString = BuildJsonObjectsUtil.generateChartData("chartId", "something", xyCollection, 0l);
View Full Code Here


        dataArraySB.append("{\"chart_model\": {\"id\": \"" + chartId + "\", \"chart_value\": \"[ ");
        int collectionIndex = 0;
        for (XYDataList list : xyCollection.getDataList()) {
            dataArraySB.append("{\\\"key\\\": \\\"").append(list.getLabel().replaceAll("\\%20", " ")).append("\\\", \\\"values\\\": [");
            for (int i = 0; i < list.size() - 1; i++) {
                XYDataPoint p = list.get(i);
                String pointLabel = "";
                if (p.getPointLabel() != null) {
                    pointLabel = ", '" + p.getPointLabel() + "'";
                }

                String yVal = null;
                if (p.getY() != null) {
                    yVal = nf.format(p.getY());
                }

                dataArraySB.append("[").append(nf.format(p.getX().longValue() + chartOffsetMs)).append(",").append(yVal).append("").append(pointLabel).append("]").append(", ");
            }

            // Last Row
            if (list.size() > 0) {
                XYDataPoint p = list.get(list.size() - 1);
                String pointLabel = "";
                if (p.getPointLabel() != null) {
                    pointLabel = ", '" + p.getPointLabel() + "'";
                }

                String yVal = null;
                if (p.getY() != null) {
                    yVal = nf.format(p.getY());
                }

                dataArraySB.append("[").append(nf.format(p.getX().longValue() + chartOffsetMs)).append(",").append(yVal).append(pointLabel).append("]");
            }

            collectionIndex++;
            dataArraySB.append("]");
            /*if (list.getColor() != null && list.getColor().length() >= 6) {
View Full Code Here

        Long currentMillis = millisStart;

        //Iterate over the time-range given and average ticks based on resolution
        while (currentMillis <= (millisEnd - (resolution * 1000))) {
            XYDataPoint currentTick = new XYDataPoint();
            currentTick.setX(currentMillis);
            currentTick.setY(null);
            double aggregatedValue = 0.0d;
            double averageValue = 0.0d;
            ValueType valueType = null;

            int numStatsInCurrentTick = 0;

            for (int i = 0; i < numTicksInResolution; i++) {
                LiveStatistics currStat = liveHash.get(currentMillis);
                if (currStat == null || currStat.getValue() == null) {
                    //No stat for this timeperiod, skipping
                } else {
                    if (valueType == null) {
                        valueType = ValueType.fromValue(currStat.getValueType());
                    }
                    //Add to current
                    aggregatedValue += currStat.getValue();
                    numStatsInCurrentTick++;
                }

                currentMillis += 15000;
            }

            if (numStatsInCurrentTick > 0) {
                //If value type is aggregate, return the aggregate value
                if (ValueType.AGGREGATE.equals(valueType)) {
                    currentTick.setY(aggregatedValue);
                } else {
                    //Otherwise return the average
                    currentTick.setY(aggregatedValue / numStatsInCurrentTick);
                }
            }

            valueList.addDataPoint(currentTick);
        }
View Full Code Here

    }   
   
    if (alert != null) {
      Double warningValue = alert.getWarningValue();
      Double errorValue = alert.getErrorValue();
      XYDataPoint startPoint = new XYDataPoint();
      startPoint.setX(minXaxis);
     
      XYDataPoint endPoint = new XYDataPoint();
      endPoint.setX(maxXaxis);
      if (alertStatus == AlertStatus.CRITICAL) {
        startPoint.setY(errorValue);
        endPoint.setY(errorValue);
      } else {
        startPoint.setY(warningValue);
        endPoint.setY(warningValue);
      }
     
      errorList.setColor("#eeff00");
      if (alertStatus == AlertStatus.CRITICAL) {
        errorList.setColor("#ff0000");
View Full Code Here

TOP

Related Classes of org.jsflot.xydata.XYDataPoint

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.