MagicMirror Forum
    • Recent
    • Tags
    • Unsolved
    • Solved
    • MagicMirror² Repository
    • Documentation
    • 3rd-Party-Modules
    • Donate
    • Discord
    • Register
    • Login
    A New Chapter for MagicMirror: The Community Takes the Lead
    Read the statement by Michael Teeuw here.

    MMM-Chart - View your graphs on your Mirror

    Scheduled Pinned Locked Moved Utilities
    21 Posts 8 Posters 19.7k Views 10 Watching
    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.
    • L Offline
      logen563 @Snille
      last edited by

      @Snille :) thanks! How do I add them? Can you send me the php script you are using? It will be a big help for me ! Thx

      1 Reply Last reply Reply Quote 0
      • SnilleS Offline
        Snille Module Developer
        last edited by

        Hi, this is a part of my php pickup/conversion script…
        I hope this can help you. :)

        // Get all the data from the database.
        foreach ($ids as $i => $idnum) {
        	//Fetches the data from MYSQL via PDO.
        	$values[] = getvalues($dbservername, $dbname, $dbusername, $dbpassword, $deftable, $defsensoridcolumn, $max, $ids[$i], $sort);
        }
        
        // Initialize the array.
        $outarray = array();
        
        $first = 0;
        
        foreach ($values as $key => $value) {
        	$position = 0;
        	foreach ($values[$key] as $i => $value) {
        		If ($first == 0) {
        			$outarray[$position][] = $values[$key][$i]["time"];
        		}
        		$outarray[$position][] = floatval($values[$key][$i]["value"]);
        		$position++;
        	}
        	$first++;
        }
        
        // Make it JSON.
        $json = json_encode($outarray);
        
        // Print it.
        echo $json;
        

        If you cant find it, make it and share it!
        Modules: MMM-homeassistant-sensors, MMM-Modulebar, MMM-Profilepicture, MMM-Videoplayer

        L 1 Reply Last reply Reply Quote 0
        • L Offline
          logen563 @Snille
          last edited by

          @Snille Thanks! Will try this ! I will let you know the results :)

          1 Reply Last reply Reply Quote 0
          • L Offline
            logen563
            last edited by

            Finally it’s working :) Thanks for the help. I use googlespread sheet, csv export, and php to convert it to json. If some somebody interested I can give some help.

            R 1 Reply Last reply Reply Quote 1
            • S Offline
              schmo90
              last edited by schmo90

              Hy it was quite hard to get the dht22 values showing up with your chart.

              finally i got the php script working to fetch mysql data to your json format:

              //your code here
              
              
              
                  //open connection to mysql db
                  $connection = mysqli_connect("localhost","logger","password","temperatures") or die("Err$
                  //fetch table rows from mysql db
                  $sql = "select * from temperaturedata";
              
                      $result = mysqli_query($connection, $sql) or die("Error in Selecting " . mysqli_erro$
              
              
                      //create an array
                      $emparray = array();
                      $position=0;
                      while($row =mysqli_fetch_assoc($result))
                      {
                            
                              $emparray[$position][] = $row['dateandtime'];
                              $emparray[$position][] = $row['temperature'];
                              $emparray[$position][] = $row['humidity'];
                              $position++;
                      }
                      echo json_encode($emparray);
                      //close the db connection
                      mysqli_close($connection);
              
              
              
              
              
              
              1 Reply Last reply Reply Quote 0
              • S Offline
                schmo90
                last edited by

                Hy i also have troubles with the real time chart.

                it shows the chart only for 0,5s and then it will disapear?

                do you ever had this issue?

                and is it possible to ad more ticks on the x-axis?
                if i display temp data from a day, it will only show two ticks

                1 Reply Last reply Reply Quote 0
                • Z Offline
                  zazzo
                  last edited by

                  Good day all,
                  i’m able to see my data locally on my php file, but unfortunately i cannot see the graph on my MM page…

                  This is what i see when i open my index.php file:

                  0_1529341523607_749d1da6-c23f-4cea-aab2-5aaeeb371376-immagine.png

                  This is the config file:

                  0_1529341634622_20521430-2cf4-4f02-a758-6db6f07de627-immagine.png

                  And this is what i see in my MM page:

                  0_1529341804193_0379380b-f35c-4c51-b1d0-c299c5caf570-immagine.png

                  Any suggestion? Consider that i’m not an expert…

                  Thanks.

                  Regards.

                  T 1 Reply Last reply Reply Quote 0
                  • S Offline
                    schmo90
                    last edited by

                    (0_1531251389830_2018-07-10 21_35_41-192.168.8.100 (mirror) – VNC Viewer.png image url)

                    I have the issue that the graph is jumping back to the beginning.

                    Has anyone else this issue?

                    @zazzo hm strange your data looks code…

                    1 Reply Last reply Reply Quote 0
                    • S Offline
                      schmo90
                      last edited by

                      Hy i solved the issue with jumping values.

                      you are deleting the y axis values in the file mmm-chart.js

                      but not the label dataarray.

                      i added the line:
                      this.chartData.labels = [];
                      at #296 and now i have fixed the jumping value issue

                      i also added the suggestedMin/Max parameter and to change the line chart to a stepped line chart

                      1 Reply Last reply Reply Quote 0
                      • R Offline
                        ricq
                        last edited by

                        @logen563 Hi. I am interested how you did this? Would like to display graph. Data is from an xml file that I download daily.

                        S 1 Reply Last reply Reply Quote 0
                        • 1
                        • 2
                        • 3
                        • 2 / 3
                        • First post
                          Last post
                        Enjoying MagicMirror? Please consider a donation!
                        MagicMirror created by Michael Teeuw.
                        Forum managed by Sam, technical setup by Karsten.
                        This forum is using NodeBB as its core | Contributors
                        Contact | Privacy Policy