Unable to create single stat using javascript

When I try to create a single stat using Javascript I’m getting this issue.

TypeError: Cannot read property 'length' of undefined
    at e.upgradeToGridLayout (dashboard_migration.ts:484)
    at e.updateSchema (dashboard_migration.ts:423)
    at e.updateSchema (dashboard_model.ts:795)
    at new e (dashboard_model.ts:90)
    at t.create (dashboard_srv.ts:132)
    at t.setupDashboardInternal (dashboard_ctrl.ts:155)
    at t.setupDashboard (dashboard_ctrl.ts:145)
    at t.init (history.ts:67)
    at t.e.initDashboard (grafana_app.ts:66)
    at app.4f5454f867a0cc2fe8dd.js:30978 true

My code is

function singleStat(){
  dashboard.rows.push({
  title: "Success Rate",
  transparent: true,
  type: "singlestat",
  cacheTimeout: null,
  colorBackground: false,
  colorValue: false,
  colors: [
    'rgba(245, 54, 54, 0.9)',
    'rgba(237, 129, 40, 0.89)',
    'rgba(61, 165, 30, 0.97)'
  ],
  datasource: "company",
  editable: true,
  error: false,
  format: "percentunit",
  gauge: {
    maxValue: 1,
    minValue: 0,
    show: true,
    thresholdLabels: false,
    thresholdMarkers: true
  },
  // height: "180",
  id: 12,
  interval: null,
  links: [],
  mappingType: 1,
  mappingTypes: [
    {
      name: "value to text",
      value: 1
    },
    {
      name: "range to text",
      value: 2
    }
  ],
  maxDataPoints: 100,
  nullPointMode: "connected",
  nullText: null,
  postfix: "",
  postfixFontSize: "50%",
  prefix: "",
  prefixFontSize: "50%",
  rangeMaps: [
    {
      from: "null",
      text: "N/A",
      to: "null"
    }
  ],
  sparkline: {
    fillColor: "rgba(31, 118, 189, 0.18)",
    full: false,
    lineColor: "rgb(31, 120, 193)",
    show: false
  },
  targets: [
    {
      dsType: "influxdb",
      groupBy: [
        {
          params: [
            "$interval"
          ],
          type: "time"
        },
        {
          params: [
            "null"
          ],
          type: "fill"
        }
      ],
      measurement: "requests",
      policy: "default",
      query: "SELECT 1 - sum(\"errorCount\")/count(\"responseTime\") FROM \"requestsRaw\" WHERE $timeFilter AND \"requestName\" =~ /^$request$/",
      rawQuery: true,
      refId: "A",
      resultFormat: "time_series",
      select: [
        [
          {
            params: [
              "value"
            ],
            type: "field"
          },
          {
            params: [],
            type: "mean"
          }
        ]
      ],
      tags: []
    }
  ],
  thresholds: "-1,-1",
  valueFontSize: "80%",
  valueMaps: [
    {
      op: "=",
      text: "N/A",
      value: "null"
    }
  ],
  valueName: "current",
  // gridPos: {
  //   x: 12,
  //   y: 24,
  //   w: 4,
  //   h: 5
  // },
  tableColumn: ""
});
}

The json is incorrect m, your adding panels to rows.

Please use the new grid position system. Try building a dashboard using UI and under settings view json to understand the json model.

I have tried creating single stat using basic panel json obtain via UI. I am not able to recognise the problem with the json. Is there any template for creating single stat