• Recent
    • Tags
    • Popular
    • Register
    • Login

    Please Note This forum exists for community support for the Mango product family and the Radix IoT Platform. Although Radix IoT employees participate in this forum from time to time, there is no guarantee of a response to anything posted here, nor can Radix IoT, LLC guarantee the accuracy of any information expressed or conveyed. Specific project questions from customers with active support contracts are asked to send requests to support@radixiot.com.

    Radix IoT Website Mango 3 Documentation Website Mango 4 Documentation Website Mango 5 Documentation Website

    DataPoint values into a var javascript

    How-To
    3
    9
    2.3k
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • D
      Davide27
      last edited by

      Hello,
      I need to insert a button in a dashboard that generates a csv file with values(included in a range of dates) of a given data point.
      Is there any way to do it?
      Or the best alternative would be to put all the values ​​of a datapoint into a javascript variable, so you can process them and then generate a csv.

      Thanks a lot.

      1 Reply Last reply Reply Quote 0
      • MattFoxM
        MattFox
        last edited by MattFox

        A similar question has already been asked,
        This asks to upload but it also contains the code required to generate a new csv.
        Assuming you are a competent programmer, this is a route you can take.
        https://forum.infiniteautomation.com/topic/4041/processing-files

        Do not follow where the path may lead; go instead where there is no path.
        And leave a trail - Muriel Strode

        1 Reply Last reply Reply Quote 0
        • Jared WiltshireJ
          Jared Wiltshire
          last edited by

          Here's an example, you can download CSV straight from the REST API

          <ma-watch-list-get ng-model="designer.watchList" parameters="designer.parameters" on-points-change="designer.points = $points" id="29305bf3-cc2a-4bac-9650-3cbf64d738a9" watch-list-xid="WL_Flow"></ma-watch-list-get>
          <div class="ma-designer-root" id="1a2a6980-f5bb-4acc-a41a-f8f69d5c12d2" style="width: 1366px; height: 768px; position: relative;">
          
              <ma-calc input="designer.points | filter:{name:'Flow'}:true | maFirst" output="point"></ma-calc>
              
              <md-button id="2585b1fa-a630-4255-8670-41884b8754e2" style="position: absolute; left: 260px; top: 70px;" class="md-raised" ng-href="/rest/v2/point-values/time-period/{{point.xid}}?fields=TIMESTAMP&fields=VALUE&fields=ANNOTATION&from={{dateBar.from.toISOString()}}&to={{dateBar.to.toISOString()}}&format=csv2" download="{{point.name}}.csv">Download values</md-button>
          </div>
          

          Developer at Radix IoT

          1 Reply Last reply Reply Quote 1
          • D
            Davide27
            last edited by

            Thanks for the answers.
            I used the Jared method and it works, but due to a problem with the data timestamp I need to have the values ​​of a data point in a javascript variable.
            Do you have any options?

            1 Reply Last reply Reply Quote 0
            • MattFoxM
              MattFox
              last edited by

              What's wrong with the time format?
              Are you opening the csv with excel or something like notepad?

              Do not follow where the path may lead; go instead where there is no path.
              And leave a trail - Muriel Strode

              1 Reply Last reply Reply Quote 0
              • Jared WiltshireJ
                Jared Wiltshire
                last edited by Jared Wiltshire

                You can add &dateTimeFormat=yyyy-MM-dd%20HH%3Amm%3Ass.SSS to the end of the URL to change the date encoding to a Excel compatible format.

                edit.
                Also, you can write a user module that loads point values using the maPointValues service and do whatever you please. Reference the thread that @MattFox linked to above for inspiration. Also search the help site and forum, there are lots of threads about user modules / components.

                Developer at Radix IoT

                1 Reply Last reply Reply Quote 0
                • D
                  Davide27
                  last edited by

                  I need to download a csv file with the values ​​of multiple data points, but not all values ​​have the same timestamp. For this reason, I would like to have the values in a variable so I can process it and write it all in one line.

                  Jared WiltshireJ 1 Reply Last reply Reply Quote 0
                  • MattFoxM
                    MattFox
                    last edited by MattFox

                    Just so I understand correctly. You want all values to appear in the same row in order for a given day/hour?
                    Timestamps will differ as no two values will ever come in at the same time.
                    But for those that do, you want them appended on the same line. Correct?

                    To make things easier, it might be better to average all of your points so all timestamps match then you can list columns as a

                    timestamp,datapoint1,datapoint2
                    

                    format.
                    Let me know your thoughts

                    Fox

                    Do not follow where the path may lead; go instead where there is no path.
                    And leave a trail - Muriel Strode

                    1 Reply Last reply Reply Quote 0
                    • Jared WiltshireJ
                      Jared Wiltshire @Davide27
                      last edited by

                      @davide27 said in DataPoint values into a var javascript:

                      I need to download a csv file with the values ​​of multiple data points, but not all values ​​have the same timestamp. For this reason, I would like to have the values in a variable so I can process it and write it all in one line.

                      Please have a play with the CSV download from the watch list. Try it with different rollup options and see if you can get something that works for you. If this suffices I can give you an example of a new URL you can use in the example I posted above.

                      The reason I am suggesting this is because it will be easier for you, I have given you suggestions on how to proceed if you really want to process the values using JavaScript but you haven't given me any indication that you have looked at the documentation I referenced.

                      Developer at Radix IoT

                      1 Reply Last reply Reply Quote 0
                      • First post
                        Last post