I have the following javaScript object
var stats = [
{x: 10, y: 300, clr:'blue'},
{x: 16, y: 600, clr:'blue'},
{x: 26, y: 300, clr:'yellow'},
{x: 36, y: 200, clr:'yellow'},
{x: 46, y: 700, clr:'green'},
{x: 56, y: 100, clr:'green'},
];
How could I able to get the following objects? Each object seperated based on clr
property The main key points are to separate and append the last object of the previous object to the first object for new object.This step is required to connect lines between.
var stats1 = [
{x:10, y:300, clr:'blue'},
{x:16, y:600, clr:'blue'},
];
var stats2 = [
{x:16, y:600, clr:'yellow'},
{x:26, y:300, clr:'yellow'},
{x:36, y:200, clr:'yellow'}
];
var stats3 = [
{x:36, y:200, clr:'green'},
{x:46, y:700, clr:'green'},
{x:56, y:100, clr:'green'}
];