Use Power BI real-time data visualization is a topic we are more concerned about pushing data show realized on the dashboard, it can be used in command of such a large screen, and other scenes.
This video combat follows: https://v.qq.com/x/page/y3030euh6do.html
Look under the effect of the figure the curve will automatically refresh:
Proceed as follows:
Create a stream of data sets, select the mode API
Azure flow analysis which, as of December 2019, China, Azure flow analysis does not support the write output directly to the Power BI.
Fill in the data set name and values and value types and open historical data analysis:
Historical data analysis which is used to temporarily hold data temporarily stored data can be presented a curve.
Creating a dashboard and instrument panel add a real-time data tile
4. Select the stream data sets already created
5. In the dashboard page to add a custom data stream tile
Select line graph visualization
"Axis" selection time
Temperature and humidity add "value"
6. Post call request illustrated by the following information data can be pushed to the data set
Postman sent the results of 200 indicates successful execution.
7. Create a report on the data set, can be used to view the results pushed POST request stream data set
8. call the following sample code:
using Newtonsoft.Json;using System;using System.IO;using System.Net;using System.Text;using System.Threading.Tasks;namespace pushdatatopowerbidataset{ class Program { private static int s_telemetryInterval = 1; // Seconds private static string PowerBIPushDataUrl = "https://api.powerbi.cn/beta/729c6bf9-debe-4b7f-b56a-5fb0c70c9a80/datasets/fc445a3c-9a25-4298-8188-89112874e5c3/rows?key=seAORXugMKybekrdRAxfSWM5o1MS%2F9d4pcPF9zAgblivdNXz9pRivqyVwAS%2FXMoo8wA01vuAu%2B2hBHI8gdAWMg%3D%3D"; private static void Main(string[] args) { Console.WriteLine("Send realtime data to power bi dataset by api. Ctrl-C to exit.\n"); SendMessageToPbiDataSetAsync(); Console.ReadLine(); } private static async void SendMessageToPbiDataSetAsync() { while (true) { // Initial telemetry values double minTemperature = 20; double minHumidity = 60; Random rand = new Random(); double currentTemperature = minTemperature + rand.NextDouble() * 15; double currentHumidity = minHumidity + rand.NextDouble() * 20; // Create JSON message var telemetryDataPoint = new { temperature = currentTemperature, humidity = currentHumidity, time=DateTime.Now }; var messageString = JsonConvert.SerializeObject(telemetryDataPoint); PostUrlAsync(PowerBIPushDataUrl, messageString); await Task.Delay(s_telemetryInterval * 1000); } } public static string PostUrlAsync(string url, string postData) { string result = ""; HttpWebRequest req = (HttpWebRequest)WebRequest.Create(url); req.Method = "POST"; req.Timeout = 8000;//设置请求超时时间,单位为毫秒 req.ContentType = "application/json"; byte[] data = Encoding.UTF8.GetBytes("["+ postData+"]"); req.ContentLength = data.Length; using (Stream reqStream = req.GetRequestStream()) { reqStream.Write(data, 0, data.Length); reqStream.Close(); } HttpWebResponse resp = (HttpWebResponse)req.GetResponse(); Stream stream = resp.GetResponseStream(); //获取响应内容 if(resp.StatusCode==HttpStatusCode.OK) { Console.WriteLine("OK"+" "+postData); } return result; } } }
At this point, you can see real-time visualization refresh the dashboard: