flutter bar charts show live data fetched from webpage - flutter

I want to plot bar charts to show live data fetched from webpage.
I have managed to get response from webpage in json format then convert it to List and plot the data, but it doesn't get refreshed.

There are 3 ways to achieve this.
Make self-calling a future method that calls itself until the screen is disposed of.
Create socket and listeners every time update data. You can listen to change and update the pie chart. Same as a real-time chat application.
You can use firebase's real-time database for this solution.Every time data update in schema,Application will state recalls via streams automatically

Related

Flutter achieving ui/data synchrony

I have two screens:
Homefeed.dart
Profile.dart
On Homefeed screen all the data from various users is fetched from a server and is shown in a list of cards form.
On the Profile screen, only data that belongs to the logged in user is fetched.
The problem is that, there will be an overlap in the data that is fetched on the both the screens. For example if a user writes a post, it can show up on the Homefeed. Now if the user decides to perform any action such as like, delete, edit etc on thir post from the profile screen, then it should also update the same post that was fetched on the Homefeed screen.
Now unless user explictly refreshes the data, and send a request to server to fetch the updated data, what would be an ideal way to achieve this synchrony.
I did consider using a realtime database, but this will mean migrating current project and it might get expensive and might have problem of it own.
The other "hacky" way would be to maniuplate data somehow (I still havent figured it out) on the client side and show the update instead of fething new data from the server.
Or some other, more ideal way of achiving this, that I don't know of.
The best way is to reflect any changes of the user post i.e edit, delete in Profile.dart is by updating the database without tricking the just in the client side. Because you may reduce the database calls by tricking, but you are giving high chances of inconsistent data in database. Your database wouldn't be reliable.
Database should be the single source of truth
I would suggest, Every time HomeFeed.dart page is loaded , try loading the latest data from the database. If you are using real-time database, you dont have to check on every page load.

request only required data from firebase realtime database flutter

Let's say I have millions of records like this. I am showing this information in GridView. It will take a lot of time to download the whole database and then display results. How do I download only 50 records at a time and when I am about to reach the end of list download another 50 and so on like Google image search results? Is it possible?
What you want is called pagination. I don't know about real-time databases but I do know firebase firestore provides you with tools to do that. You could check this link out for firebase firestore.
https://www.youtube.com/watch?v=poqTHxtDXwU&feature=emb_logo
You can write code to fetch specific data then add a scrollController to page and a code to fetch next data whenever your scrollController reaches bottom of page.
For it you have to learn using scrollController.
https://youtu.be/pGmHYXC5MeU

How to save data in flutter?

I am building an app like google's keep (notes taking app) using flutter. I can add notes but when I close the app, it resets to initial state. How can I save these notes so when I come back to app, I can read my previously added notes.
When you're saving in a list for example, and render, you're doing that on UI state which is temporary. If you want to store data to last even after the UI got refreshed, you have to use a database that will hold the data until you delete it.
If you just want to store some tiny data, for example light/dark mode preferences or login/logout sessions, you can use shared_preferences. For larger data, I used sqflite to store data in SQL database in system as a file which will be cleared after the app is memory-cleared or deleted. If you want to store the data in cloud, you can use firebase for that.
You have two options:
1) Save locally on device using database. Below are the db solutions.
Moor
Floor
2) Save on the server, you can use Firebase Cloud Firestore.

how does grafana work by ploting graphs at regular intervals

i'm new to Grafana i want information regarding the back end operation of Grafana,how it works using java script?and how the graph will plot continuously at regular time_interval
The Grafana docs has some of information you are looking for.
Reg the internal working.
Taking example of graph panel.
A service called timeSrv broadcasts a refresh event depending on the timer set on the dashboard.
This request is caught at several places in grafana. The one we are interested in is MetricsPanelCtrl which is a parent of the graph panel.
From there it issues a call to the data-source query method, which will fetch the data.
Once the data has been recieved, it emits a 'data-received' event, with is caught and handled by the graph panel controller to render the graph.

ios swift - load multiple data source in one tableview synchronously

i want a make a feed reader...i want load politics news from multiple data dource in one tableview synchronously.
what do i do?
i went to this link: table view with multiple data sources/nibs
but this solution is not synchronously
So basically what should be the approach when we have multiple data source but single instance of table view to show the data?
What I would do is to create a backend service where the news are merged into one list. This allows you to easily edit the algorithm without the user having to update the app. And your backend also only have to crawl the websites once instead of every client having to do it every time a user wants to see the news.
When you fetch data from that service it will come in one list, and you already know how to do that :)
It shouldn't be synchronously, because you wait for the rss response.
You better show a spinner and reload the tableview data once you collect all the responses.