Home > Back-end >  Cannot convert undefined or null object
Cannot convert undefined or null object

Time:01-10

Been sat down trying to work this out for ages:/ telling me that it cannot convert undefined or null object. Any help would be very much appreciated:( Am trying to show the volume of trade of these major indexes. Am using the vega documentation and using different templates but nothing seems to be working for the visualisation i want to show

{"$schema": "https://vega.github.io/schema/vega-lite/v5.json",
 
  "title": {
     "text": "Trading volume of 5 major stock indexes from 2018-2022",
     "subtitle":"Source: Yahoo Finance.",
     "subtitleFontStyle":"italic",
     "subtitleFontSize":10,
     "anchor": "start",
     "color": "black"
   },
 
 
   "description": "volume of stocks",
 
   "data": {
     "url": "https://raw.githubusercontent.com/andrewsnowdon/andrewsnowdon.github.io/main/graph1megasheet.csv",
     "format": {"type": "csv"}
   },
   
     "height": 300,
   "width": 300,
   
   "mark": {"type": "area", "point": "false"},
   
   "selection": {
     "Stockname": {"type": "single", "fields": ["Stockname"], "bind": {"input": "select",
     "options": [
          "DAX",
          "DOWJONES",
          "FTSE100",
          "NASDAQ",
          "S&P500"
        ],

      "name": "Select Index: "}
   },
     
   "encoding": {
     "x": {
       "field": "Date", 
       "type": "temporal", 
       "title": null, 
       "axis":{"grid":false}
       },
 
     "y": {
       "field": "Volume",
       "type": "quantitative",
       "title": null,
       "axis":{"grid":false}
       },
 
     "color": {
       "field": "Stockname",
       "type": "nominal",
       "scale": {"scheme": "inferno"},
       "title": null,
       "legend": {
         "orient": "bottom",
         "columns":2, 
         "fillColor": "#FcFdFd"}
     },
     "opacity": {"condition": {"selection": "region", "value": 1}, "value": 0.1}        
   }
 }}

CodePudding user response:

Cannot convert undefined or null object errors will not be in your JSON schema that you shared. It would likely be a problem with the code referring to this schema. Either you are not actually getting the schema, or there is possibly a typo in the call.

CodePudding user response:

You must have class with same properties as the JSON that you have. For instance, if one property in you class has all characters with lowercase and JSON has the first char uppercase then it will be null.

  •  Tags:  
  • Related