These are chat archives for systemjs/systemjs

20th
Apr 2017
symphony
@symphony2014
Apr 20 2017 12:00
Anybody can help me , about deep copy, every time I execute the "children.push(n)", the other element style of children will be changed, so weird, anybody can help me ?
this.result=[{"Legend":["北京","上海","广州"],"AlgorithmId":"170419184731779001","Text":"城市","Series":[{"Name":"一月","Values":["132","22","35"]},{"Name":"二月","Values":["25","30","34"]},{"Name":"三月","Values":["17","32","23"]}],"XAxis":["一月","二月","三月"]},{"AlgorithmId":"0002","Text":"平均值","Legend":["平均值"],"Series":[{"Name":"一月","Values":["3"]},{"Name":"二月","Values":["3"]},{"Name":"三月","Values":["3"]}]},{"Legend":["北京","上海","广州"],"AlgorithmId":"0","Text":"城市","Series":[{"Name":"一月","Values":["132","22","35"]},{"Name":"二月","Values":["25","30","34"]},{"Name":"三月","Values":["17","32","23"]}],"XAxis":["一月","二月","三月"]},{"Legend":["北京","上海","广州"],"AlgorithmId":"0","Text":"城市","Series":[{"Name":"一月","Values":["132","22","35"]},{"Name":"二月","Values":["25","30","34"]},{"Name":"三月","Values":["17","32","23"]}],"XAxis":["一月","二月","三月"]}];
        schema={"series":[],"sum":11111,"sumtime":200,"graphic":[{"AlgorithmId":"0","id":"logo","type":"group","left":"center","top":"center","children":[{"type":"text","z":100,"left":"left","top":90,"style":{"text":"整体环比","fill":"#000","font":"14px Microsoft YaHei"}},{"type":"image","z":100,"top":72,"left":60,"style":{"image":"","font":"14px Microsoft YaHei"}},{"type":"text","z":100,"left":95,"top":90,"style":{"text":"60%","fill":"#000","font":"14px Microsoft YaHei"}}]}]};

        var children=[];

          this.result[0].Series.map((s,i)=>{
            var newChildren=[
                Object.assign({},schema.graphic[0].children[0]),
                Object.assign({},schema.graphic[0].children[1]),
                Object.assign({},schema.graphic[0].children[2]),
            ];

             newChildren[0].style.text=s.Name;
             newChildren[2].style.text=s.Values[0];

             let maxFontSize=0;
             newChildren.map(n=>n.style.font.match(/\d+/g).map(f=>{
                                              if (f>maxFontSize)
                                              maxFontSize=Number(f);
                                          }));

             newChildren.forEach(n=>{
                 n.top+=i*maxFontSize;
                 children.push(n);
            });  
            console.log(children);
          }
          );
          schema.graphic[0].children=children;
every first element of children style.text will be changed to the last value, after execute children.push(n);??
Anybody can help me?
symphony
@symphony2014
Apr 20 2017 12:06
The other element of children will be changed after execute children.push(n), it's so weird , @all, help..