0

I am looking for the best way of processing data for my charts.

At the moment, every time I need to show my charts I use ajax to get the data, then process it and finally show it on the charts.

The problem is that sometime there’s a lot of data to grab from the api so I’m thinking about getting the whole data when the page loads and storing it locally.

Then, every time I need to populate the charts I just process the data locally and there’s no extra ajax calls to make to the api.

My problem is that local storage has a maximum of 10MB and I might need more than that at some point in time.

Other than that, what are my choices here if I don’t want to use a local database?

  • 2
    why aren't you summarize data on server side? – mkysoft Sep 15 '16 at 15:24
  • Storing more than 10mb on the user's browser is pretty irresponsible IMO. Using Ajax to retrieve small amounts of data as its needed is the most logical way to do it. If you have API limits, retrieve the data and store it locally. – Tom Sep 15 '16 at 15:29
  • 1
    Are your charts still readable with above 10MB of data? You could simplify your data using [Ramer–Douglas–Peucker algorithm](https://en.wikipedia.org/wiki/Ramer%E2%80%93Douglas%E2%80%93Peucker_algorithm). – Lukasz Wiktor Sep 15 '16 at 15:31
  • 1
    i think you get the answer from this related question: [link](http://stackoverflow.com/questions/6589134/combining-html5-localstorage-and-local-database-for-more-space) – dhamo dharan Sep 15 '16 at 15:32
  • Good points ... I think I might be able to use localstorage after all by simplyfings the data as @Ramer-Douglas suggested –  Sep 15 '16 at 15:43

1 Answers1

0

You could use local storage:

if (typeof (Storage) !== "undefined") {
//store ajax data local
//set variable that local storage is aviable
} else {
// set variable that local storage is not aviable
}

Than check before processing data if you need ajax or grab localstorage.

Timo Reymann
  • 755
  • 5
  • 16