Skip to Main Content

APEX

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Fusioncharts thermometer gauge

Padmocho-OracleAug 15 2016 — edited Aug 17 2016

Hi All,

I am not an expert in JavaScript but I know my way around Apex fair enough. So, I would like to integrate this nice thermometer gauge in my apex application: Introduction to Thermometer Gauge

I have created a new page where in the page HTML header section I have copied all the javascript code:

<script type="text/javascript" src="http://static.fusioncharts.com/code/latest/fusioncharts.js"></script>

<script type="text/javascript" src="http://static.fusioncharts.com/code/latest/themes/fusioncharts.theme.fint.js?cacheBust=56"></script>

<script type="text/javascript">

  FusionCharts.ready(function(){

    var fusioncharts = new FusionCharts({

    type: 'thermometer',

    renderAt: 'chart-container',

    id: 'myThm',

    width: '240',

    height: '310',

    dataFormat: 'json',

    dataSource: {

        "chart": {

            "caption": "Temperature Monitor",

            "subcaption": " Central cold store",

            "lowerLimit": "-10",

            "upperLimit": "0",

            "decimals": "1",

            "numberSuffix": "°C",

            "showhovereffect": "1",

            "thmFillColor": "#008ee4",

            "showGaugeBorder": "1",

            "gaugeBorderColor": "#008ee4",

            "gaugeBorderThickness": "2",

            "gaugeBorderAlpha": "30",

            "thmOriginX": "100",

            "chartBottomMargin": "20",

            "valueFontColor": "#000000",

            "theme": "fint"

        },

        "value": "-6",

        //All annotations are grouped under this element

        "annotations": {

            "showbelow": "0",

            "groups": [{

                //Each group needs a unique ID

                "id": "indicator",

                "items": [

                    //Showing Annotation

                    {

                        "id": "background",

                        //Rectangle item

                        "type": "rectangle",

                        "alpha": "50",

                        "fillColor": "#AABBCC",

                        "x": "$gaugeEndX-40",

                        "tox": "$gaugeEndX",

                        "y": "$gaugeEndY+54",

                        "toy": "$gaugeEndY+72"

                    }

                ]

            }]

        },

    },

    "events": {

        "initialized": function(evt, arg) {

            evt.sender.dataUpdate = setInterval(function() {

                var value,

                    prevTemp = evt.sender.getData(),

                    mainTemp = (Math.random() * 10) * (-1),

                    diff = Math.abs(prevTemp - mainTemp);

                diff = diff > 1 ? (Math.random() * 1) : diff;

                if (mainTemp > prevTemp) {

                    value = prevTemp + diff;

                } else {

                    value = prevTemp - diff;

                }

                evt.sender.feedData("&value=" + value);

            }, 3000);

            updateAnnotation = function(evtObj, argObj) {

                var code,

                    chartObj = evtObj.sender,

                    val = chartObj.getData(),

                    annotations = chartObj.annotations;

                if (val >= -4.5) {

                    code = "#00FF00";

                } else if (val < -4.5 && val > -6) {

                    code = "#ff9900";

                } else {

                    code = "#ff0000";

                }

                annotations.update("background", {

                    "fillColor": code

                });

            };

        },

        'renderComplete': function(evt, arg) {

            updateAnnotation(evt, arg);

        },

        'realtimeUpdateComplete': function(evt, arg) {

            updateAnnotation(evt, arg);

        },

        'disposed': function(evt, arg) {

            clearInterval(evt.sender.dataUpdate);

        }

    }

}

);

    fusioncharts.render();

});

</script>

Then, created a new region and in that region in Text section I placed:

<div id="chart-container">FusionCharts XT will load here!</div>

This works fine on my local Apex instance.

However, when I try to copy exactly the same code to apex.oracle.com - I don't see any charts being generated.

Could anyone explain why?

I am sure it has to do with the inclusion of the js scripts:

<script type="text/javascript" src="http://static.fusioncharts.com/code/latest/fusioncharts.js"></script>

<script type="text/javascript" src="http://static.fusioncharts.com/code/latest/themes/fusioncharts.theme.fint.js?cacheBust=56"></script>

but if it works on my local machine - why doesn't it work on public apex.oracle.com site?

Second issue is that as per FusionCharts instructions I need 2 files to display the chart fusioncharts.js and fusioncharts.chart.js I have uploaded them to static files in apex - but referencing them by #APEX_IMAGES#.... also doesn't work.

Is there any way to display the thermometer gauge in an application on apex.oracle.com site?

Regards,

Pawel.

This post has been answered by InoL on Aug 17 2016
Jump to Answer
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Sep 14 2016
Added on Aug 15 2016
9 comments
1,643 views