Angular 5 chart trouble

Angular 5 chart trouble
0.0 0

#1

constructor(private afa:ChartsService) {

  this.dataSource = {
      "chart": {
          "caption": "Harry's SuperMart",
          "subCaption": "Top 5 stores in last month by revenue",
          "numberprefix": "$",
          "theme": "fint"
      },
      "data": [
          {
              "label": "Captain Kirk",
              "value": `${this.obj}`
          },
          {
              "label": "Captain America",
              "value": `${this.obj2}`
          },
          
      ]
  }

}
I try making a simple app, with instructions but in angular is it even possible to make a json snippet
update dynamically liket in my case i try in my best to update the obj values
in realtime but json doesnt seem want it.
Can i translate this chart json snippet somehow so i can update it realtime?


#2

Usually you should avoid working with JSON data directly. JSON is used to serialize data. For example, when data is sent with an HTTP request it is changed into JSON.

But JSON is not an object. It’s a string. Or, to be clear, it is an object represented by a string (or stringified). Because of this, you cannot work with JSON in your app. If you have JSON data, you should called JSON.parse() which will return an object.

Your example is a bit strange. It looks like JSON because the property names are in quotes. But it is not valid JSON because the whole object is not in quotes. Also you have some template literals (strings with ``) which are not valid JSON.


#3

I solved the puzzle took me 3 days… thanks anyways