title: Chart: Datasets with non-synchronized timestamps, how to recalculate to sync?
body: <p>I have an arbitrary number of datasets composed of a timestamp (x-axis) and a value (y-axis).</p>
  
  <p>I need to display all the datasets on the same chart.</p>
  
  <p><strong>Problem is:</strong>
  The timestamps in all datasets are in the same range, but are not synchronized and not at a regular interval.</p>
  
  <p>I need to find an algorithm that will allow me to recalculate each dataset to have a regular interval, with all the datasets being synced on the same timestamp.</p>
  
  <p>That involves data-grouping, but I can't find a way to do that despite hours of research and trials.</p>
  
  <p>Do you know an algorithm that can do that, or point me in the right direction?</p>
  
  <p>Example of datasets:</p>
  
  <pre><code>$datasets = array("Obama"=&gt;array(array(1349302804000,-0.01816786389414),array(1349301604000,0.012345040580335),array(1349300404000,-0.033756646856428),array(1349299204000,-0.006286872863163),array(1349297952000,-0.0074601175482789),array(1349296805000,-0.010973443467448),array(1349295604000,-0.005568970434452),array(1349294404000,-0.0012120259794678),array(1349293204000,0.015711233554481),array(1349292004000,0.016875),array(1349290804000,0.022688596491228),array(1349289604000,0.019734841788934),array(1349288404000,0.00093237032173337),array(1349287203000,0.047540149892934),array(1349286003000,0.050829994275902),array(1349284804000,0.050869565217392),array(1349283603000,0.044487102579484),array(1349282404000,0.017858701582106),array(1349281204000,0.0087304224015187),array(1349280003000,0.028488752556237),array(1349278804000,0.024093464511595),array(1349277604000,0.048635340039033),array(1349276404000,0.04042026755061),array(1349275204000,0.0068150826446279),array(1349274004000,-0.0047961420429636),array(1349272805000,-0.010688066893424),array(1349271604000,-0.035958462777586),array(1349270404000,-0.0056705108654213),array(1349269205000,-0.0022607126428647),array(1349268005000,-0.014915393322015),array(1349266805000,-0.0053641177194927),array(1349265606000,-0.014968247147018),array(1349264405000,-0.020219280396427),array(1349263205000,-0.04449370409234),array(1349262006000,-0.027506361323155),array(1349260806000,-0.038331137978078),array(1349259607000,-0.072457013890502),array(1349258405000,-0.049677654675601),array(1349257205000,-0.063347322517114),array(1349256006000,0.077658552832438),array(1349254804000,0.077278732644198),array(1349253604000,0.059828414180112),array(1349252405000,0.040018753516285),array(1349251204000,0.047372475045194),array(1349250004000,0.091023835864428),array(1349248804000,0.060634174421952),array(1349247603000,0.1024280240832),array(1349246404000,0.086939465674671),array(1349245204000,0.055583928780602),array(1349244004000,0.10744203165256)),"Romney"=&gt;array(array(1349302803000,0.081436305930674),array(1349301602000,0.094257877535919),array(1349300403000,0.076450368766494),array(1349299203000,0.074385681801511),array(1349297951000,0.084889532226116),array(1349296803000,0.073218018309974),array(1349295602000,0.071383950822397),array(1349294403000,0.079591779279279),array(1349293203000,0.10141599920894),array(1349292003000,0.084515383807623),array(1349290802000,0.093798124383021),array(1349289603000,0.08621332562509),array(1349288403000,0.0746714922049),array(1349287202000,0.089265161575918),array(1349286002000,0.098435714285715),array(1349284803000,0.10246532759445),array(1349283602000,0.043511846001974),array(1349282403000,0.099958158995816),array(1349281203000,0.037493219682294),array(1349280002000,0.064469820554649),array(1349278803000,0.03996714755035),array(1349277602000,0.063711977186311),array(1349276403000,0.044796065953139),array(1349275203000,0.032955928901875),array(1349274003000,0.012628563344416),array(1349272803000,0.011735430052982),array(1349271602000,0.046707778556412),array(1349270403000,0.051073749433278),array(1349269203000,0.064878575931317),array(1349268003000,0.07278246496941),array(1349266803000,0.063141113073809),array(1349265604000,0.10484914372815),array(1349264403000,0.10646994729937),array(1349263203000,0.066190820620726),array(1349262003000,0.052965085522837),array(1349260804000,0.0057958228303921),array(1349259604000,-0.047100507799987),array(1349258403000,-0.11577136713851),array(1349257203000,-0.095616277524257),array(1349256004000,-0.039400427733014),array(1349254802000,0.056399485640806),array(1349253602000,0.064254375154056),array(1349252403000,0.058393178383823),array(1349251202000,0.11691703201258),array(1349250003000,0.079696498054474),array(1349248803000,0.00089036795177686),array(1349247602000,0.060458641560188),array(1349246403000,0.0051984375000001),array(1349245203000,0.017228566558718),array(1349244003000,0.031592306166964)),"volumes"=&gt;array(array(1349302803000,24819),array(1349301602000,25088),array(1349300403000,23376),array(1349299203000,21656),array(1349297951000,21527),array(1349296803000,19906),array(1349295602000,18381),array(1349294403000,16922),array(1349293203000,16153),array(1349292003000,14900),array(1349290802000,12714),array(1349289603000,10908),array(1349288403000,8741),array(1349287202000,7378),array(1349286002000,7080),array(1349284803000,6710),array(1349283602000,6612),array(1349282403000,7677),array(1349281203000,8285),array(1349280002000,10262),array(1349278803000,11634),array(1349277602000,13571),array(1349276403000,16190),array(1349275203000,19376),array(1349274003000,22452),array(1349272803000,28221),array(1349271602000,33545),array(1349270403000,40681),array(1349269203000,51071),array(1349268003000,61082),array(1349266803000,65550),array(1349265604000,65947),array(1349264403000,65950),array(1349263203000,65950),array(1349262003000,65923),array(1349260804000,65948),array(1349259604000,65950),array(1349258403000,65953),array(1349257203000,65928),array(1349256004000,65115),array(1349254802000,35906),array(1349253602000,27129),array(1349252403000,23694),array(1349251202000,20419),array(1349250003000,13987),array(1349248803000,13272),array(1349247602000,12476),array(1349246403000,11415),array(1349245203000,10867),array(1349244003000,9784)));
  </code></pre>
  
  <p>Thanks.</p>
  
  <p><strong>PS:</strong> Displaying the data is not an issue, and I'm not free to change the charting library (using Highstocks). My issue is only on recalculating the dataset.</p>