javascript/highchart append value to an existing series -


i have highchart potentially receives data duplicate keys, wondering how can build logic that'll merge 2 key/values 1 series.

this data

var dataarray = [{  errordate: "2017-09-07",  brand: "toyota",  count: 3 }, {  errordate: "2017-09-02",  brand: "ford",  count: 258 }, {  errordate: "2017-09-03",  brand: "ford",  count: 239 }, {  errordate: "2017-09-04",  brand: "ford",  count: 197 }, {  errordate: "2017-09-05",  brand: "ford",  count: 187 }, {  errordate: "2017-09-06",  brand: "ford",  count: 418 }, {  errordate: "2017-09-07",  brand: "ford",  count: 344 }, {  errordate: "2017-09-03",  brand: "mercedes",  count: 43 }, {  errordate: "2017-09-04",  brand: "mercedes",  count: 220 }, {  errordate: "2017-09-03",  brand: "chrysler",  count: 3 }, {  errordate: "2017-09-04",  brand: "chrysler",  count: 3 }, {  errordate: "2017-09-06",  brand: "chrysler",  count: 6 }, {  errordate: "2017-09-07",  brand: "chrysler",  count: 1 }]; 

i have keys 'ford' , 'ford' , want accomplish merge 2 , append there values under 1 series.

here fiddle: https://jsfiddle.net/pvbtmx2j/

try this: https://jsfiddle.net/pegla/tld9711z/2/

var dataarray = [{   errordate: "2017-09-07",   brand: "toyota",   count: 3 }, {   errordate: "2017-09-02",   brand: "ford",   count: 258 }, {   errordate: "2017-09-03",   brand: "ford",   count: 239 }, {   errordate: "2017-09-04",   brand: "ford",   count: 197 }, {   errordate: "2017-09-05",   brand: "ford",   count: 187 }, {   errordate: "2017-09-06",   brand: "ford",   count: 418 }, {   errordate: "2017-09-07",   brand: "ford",   count: 344 }, {   errordate: "2017-09-03",   brand: "mercedes",   count: 43 }, {   errordate: "2017-09-04",   brand: "mercedes",   count: 220 }, {   errordate: "2017-09-03",   brand: "chrysler",   count: 3 }, {   errordate: "2017-09-04",   brand: "chrysler",   count: 3 }, {   errordate: "2017-09-06",   brand: "chrysler",   count: 6 }, {   errordate: "2017-09-07",   brand: "chrysler",   count: 1 }, {   errordate: "2017-09-04",   brand: "ford",   count: 22 }, {   errordate: "2017-09-06",   brand: "ford",   count: 25 }, {   errordate: "2017-09-07",   brand: "ford",   count: 63 }].reduce((prevval, currval, index) => {   currval.brand = currval.brand.replace(/\b\w/g, l => l.touppercase());   prevval.push(currval);   return prevval; }, []); 

if want merge further date - need modify reduce function, , chose higher value or smaller value or add 1 another.


Comments

Popular posts from this blog

ios - MKAnnotationView layer is not of expected type: MKLayer -

ZeroMQ on Windows, with Qt Creator -

unity3d - Unity SceneManager.LoadScene quits application -