• ThomasEinasto ThomasEinasto

    Just a bump on this thread because the problem is still relevant for 3.x versions and probably 4.x if AmCharts 3.x is used there also.

    As analyzing the problem I think the problem lies with the API updating some data where graphs gets nulled straight after Mango updates values using <ma-get-point-values>.

    For fix basically add try {}catch(e){} method on the underlying loop where the bug happens (handleCursorMove method) and this seems to help with the graph not freezing.


    Navigate to /mango_root/web/modules/mangoUI/web

    Open amcharts.js

    search in file for following:

    if (this.prevCursorItem != s || c != this.prevMostCloseGraph) {

    After this add


    Now search in the file for following (should be basically quite close to previous search.

    this.prevCursorItem = s

    Add after that following


    Then save the file and update cache as amcharts is cached with a version. Now your chart should not freeze while cursor is on the chart. Basically you can do it with overrides folder also as Mango updates will probably lose the fix.

    Pretty printed whole handleCursorMove method with added fix. see Fix start and Fix end comments

    handleCursorMove: function(t) {
              , t);
                        var e =
                          , i = this.categoryAxis;
                        if (t.panning)
                        else if (this.chartData && !e.isHidden) {
                            var s, r = this.graphs;
                            if (r)
                                if (s = i.xToIndex(this.rotate ? t.y : t.x),
                                s = this.chartData[s]) {
                                    var n, a, o, c;
                                    if (e.oneBalloonOnly && e.valueBalloonsEnabled) {
                                        var h = 1 / 0;
                                        for (n = r.length - 1; 0 <= n; n--)
                                            if ((a = r[n]).balloon.enabled && a.showBalloon && !a.hidden) {
                                                if (o =,
                                                o = s.axes[o].graphs[],
                                                e.showNextAvailable && isNaN(o.y) && !(o = this.getNextItem(o)))
                                                o = o.y,
                                                "top" == a.showBalloonAt && (o = 0),
                                                "bottom" == a.showBalloonAt && (o = this.height);
                                                var l = e.mouseX
                                                  , g = e.mouseY;
                                                (o = this.rotate ? Math.abs(l - o) : Math.abs(g - o)) < h && (h = o,
                                                c = a)
                                        e.mostCloseGraph = c
                                    if (this.prevCursorItem != s || c != this.prevMostCloseGraph) {
                                        /*start of fix*/
                                        try {
                                            for (h = [],
                                            n = 0; n < r.length; n++)
                                                o = (a = r[n]),
                                                o = s.axes[o].graphs[],
                                                e.showNextAvailable && isNaN(o.y) && !(o = this.getNextItem(o)) && a.balloon ? a.balloon.hide() : c && a != c ? (a.showGraphBalloon(o, e.pointer, !1, e.graphBulletSize, e.graphBulletAlpha),
                                                a.balloon.hide(0)) : e.valueBalloonsEnabled ? (a.balloon.showBullet = e.bulletsEnabled,
                                                a.balloon.bulletSize = e.bulletSize / 2,
                                                t.hideBalloons || (a.showGraphBalloon(o, e.pointer, !1, e.graphBulletSize, e.graphBulletAlpha),
                                                a.balloon.set && h.push({
                                                    balloon: a.balloon,
                                                    y: a.balloon.pointToY
                                                }))) : (a.currentDataItem = o,
                                                a.resizeBullet(o, e.graphBulletSize, e.graphBulletAlpha));
                                            e.avoidBalloonOverlapping && this.arrangeBalloons(h),
                                            this.prevCursorItem = s
                                            /*end of fix*/
                                        } catch (e) {}
                                    this.prevMostCloseGraph = c
                            r = A.fitToBounds(t.x, 0, e.width),
                            c = A.fitToBounds(t.y, 0, e.height),
                            i.showBalloon(r, c, e.categoryBalloonDateFormat, t.skip),

    posted in User help read more
  • ThomasEinasto ThomasEinasto

    Can you show your whole method instead of the error? Cant really help otherwise. Also version of Mango would also be helpful to know as 4.x has some major changes in scripting env.

    posted in How-To read more
  • ThomasEinasto ThomasEinasto

    Have you read ?

    Look at Statistical objects section. Hint, there is a delta in statistical object.

    posted in Scripting general Discussion read more
  • ThomasEinasto ThomasEinasto

    @ristola said in Hiding Dashboard Elements if DataPoints are Disabled.:

    Sorry, perhaps I am not describing my intention clearly.

    Using a ma-gauge-chart.
    When disabling the datasource this is what I get.
    Instead of the red cross hatch, I am trying to make the gauge not show at all.

    In the dashboard designer under the properties, Under the Advanced CSS's display property, I can manually set to "none" and it hides it but not sure how to set it with the point.enabled flag.

    The Angular JS, the ng-hide / show causes the red cross hatch.

    Screen Shot 2021-04-03 at 2.13.57 PM.png

    When disabling the datasource this is what I get.

    That's what's wrong and why you see this like that. Disabling datasources and disabling datapoints are different methods so seeing this is actually intended. If you want it also to remove based on datasource state then do a datasource query like this

    <!-- Get our point based on xid -->
    <ma-get-point-value point-xid="dp_2323fsadilj" point="point"></ma-get-point-value>
    <!-- Get our datasource based on point datasource xid -->
    <ma-data-source-query data-sources="dataSourcesArray" query="{xid: point.dataSourceXid}" limit="10"></ma-data-source-query>
    <!-- Hide element when datasource is not enabled or point is not enabled -->
    <div ng-hide="!dataSourcesArray[0].enabled || !point.enabled">
    <span ng-bind="point.value"></span>

    posted in Dashboard Designer & Custom AngularJS Pages read more
  • ThomasEinasto ThomasEinasto

    Not quite sure how you are implementing it right now so I guess there is something else you are not saying. You are saying that on following example which I provided this part does not disappear if you disable the datapoint?

    <div ng-show="point.enabled">
    <span ng-bind="point.value"></span>

    posted in Dashboard Designer & Custom AngularJS Pages read more
  • ThomasEinasto ThomasEinasto

    As ng-hide and ng-show utilize boolean inputs so you can put like

    <ma-get-point-value point-xid="dp_2323fsadilj" point="point"></ma-get-point-value>
    <!-- point.enabled is boolean which can be inserted into ng-show so following div will show only when point is enabled -->
    <div ng-show="point.enabled">
    <span ng-bind="point.value"></span>
    <!-- Following will show all keys available in point object -->
    {{point | json}}

    posted in Dashboard Designer & Custom AngularJS Pages read more
  • ThomasEinasto ThomasEinasto

    You answered your own question. Datapoint from <ma-get-point-value> has .enabled key which you can use together with ng-show to hide/show elements based on enabled configuration.

    posted in Dashboard Designer & Custom AngularJS Pages read more
  • ThomasEinasto ThomasEinasto

    Dao and serotonin stuff are Mango backend in Java. As Scripting in Mango allows users to write either in Java or Javascript you are able to initiate backend functions also easily. This in return allows users to search around IAS Github but without documentation. e.g. you can get points and set them also using Java methods if you know how to access them instead of adding points to context in the DS.

    posted in How-To read more
  • ThomasEinasto ThomasEinasto


    I would suggest searching the forums first. There is a thread for that and an answer by @CraigWeb

    @craigweb said in Calling JSON store item in scripting datasource:

    Hi @ThomasEinasto

    Here is some extracts of a scripting data source I did recently minus the logic I did on the JSON.

    var dao = com.serotonin.m2m2.db.dao.JsonDataDao.instance;
    var objectMapper = com.serotonin.m2m2.Common.getBean(com.fasterxml.jackson.databind.ObjectMapper.class, "daoObjectMapper");
    var jsonDataVo = dao.getByXid('8b203a82-166a-4963-8dc5-17bba149e28b');
    var dataAsString = jsonDataVo.jsonData.toString();
    var data = JSON.parse(dataAsString);

    You can now edit the data object as you would normally in JS

      var newJsonData = objectMapper.readTree(JSON.stringify(data)); 
     //If objectmapper is not used before saving, all objects get saved as an array.

    To save back to the JSON store.

    posted in How-To read more
  • ThomasEinasto ThomasEinasto

    Interestingly i have just tested it out and it seems that there is some kind of a rounding thing coming up with values being exactly the threshold value. If value changes next fraction of the threshold then this does not happen.

    A quick test

    Create a virtual point with exact settings

    Current value 1
    Set point to 1.01
    No logging
    Set point back to 1.0
    Set point to 1.011
    Logging appears

    If going to other way around

    Current value 1.01
    Set point to 1.00
    Logging appears

    I am guessing datalogging does not happen if new value is greater than current value in the defined threshold but if new value is lower then current value in the defined threshold then logging works correctly.

    I might also fish out an idea that @Nurr polling time is related to the issue (I guess it might be once per minute?) where the cached value is the new over threshold limit but it does not get logged but still triggers a reset for interval logging and then it has been the same for 5 minutes and then it gets logged by the interval logging sequence.

    But still even though this happens, interval logging still works in my instance so I guess this information is not actually so relevant.

    posted in User help read more