ANovokmet / svelte-gantt

:calendar: Interactive JavaScript Gantt chart/resource booking component

Home Page:https://anovokmet.github.io/svelte-gantt/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Error: "rows" is not set

tegaologe opened this issue · comments

Thank you for the great work.

I am getting error Error: "rows" is not set.

I think I am setting the rows correctly, but i keep the same error.

`
const data = {
rows: [{
id: 1,
label: "Accounting",
}, {
id: 2,
label: "Business Development",
}, {
id: 3,
label: "Ida Flewan"
}, {
id: 4,
label: "Lauréna Shrigley"
}, {
id: 5,
label: "Ange Kembry"
}],
tasks: [{
id: 3,
resourceId: 1,
label: "PET-CT",
from: this.time("13:30"),
to: this.time("15:00"),
classes: "orange"
}, {
id: 4,
resourceId: 1,
label: "Auditing",
from: this.time("9:30"),
to: this.time("11:30"),
classes: "orange"
}, {
id: 5,
resourceId: 2,
label: "Security Clearance",
from: this.time("15:15"),
to: this.time("16:00"),
classes: "green"
}, {
id: 6,
resourceId: 2,
label: "Policy Analysis",
from: this.time("14:00"),
to: this.time("17:00"),
classes: "blue"
}, {
id: 7,
resourceId: 2,
label: "Xbox 360",
from: this.time("13:00"),
to: this.time("14:00"),
classes: "blue"
}, {
id: 8,
resourceId: 3,
label: "GNU/Linux",
from: this.time("14:00"),
to: this.time("15:30"),
classes: "blue"
}, {
id: 9,
resourceId: 4,
label: "Electronic Trading",
from: this.time("15:00"),
to: this.time("17:00"),
classes: "green"
}, {
id: 10,
resourceId: 5,
label: "Alternative Medicine",
from: this.time("14:30"),
to: this.time("15:30"),
classes: "orange"
}],
dependencies: []
}

  let options = {
    dateAdapter: new MomentSvelteGanttDateAdapter(moment),
    rows: data.rows,
    tasks: data.tasks,
    dependencies: data.dependencies,
    timeRanges: [],
    columnOffset: 15,
    magnetOffset: 15,
    rowHeight: 52,
    rowPadding: 6,
    headers: [{unit: 'day', format: 'MMMM Do'}, {unit: 'hour', format: 'H:mm'}],
    fitWidth: true,
    minWidth: 800,
    from: currentStart,
    to: currentEnd,
    tableHeaders: [{title: 'Label', property: 'label', width: 140, type: 'tree'}],
    tableWidth: 240,
    ganttTableModules: [SvelteGanttTable],
    ganttBodyModules: [SvelteGanttDependencies]
  }

  this.gantt =  new SvelteGantt(document.getElementById("ganttChart"), options);

`

commented

Hello, yes the structure of your data object seems correct, could you please link your entire code so I might give it a look ?

Here is the code? No idea what to do? I like the project.

`

` ` <script> import {mainStore} from "stores/main"; import {DataStore, Predicates, SortDirection} from "@aws-amplify/datastore"; import {Companies, Locations, Trip} from "src/models"; //import dayjs from 'dayjs'; import moment from 'moment'; import { SvelteGantt, SvelteGanttDependencies, SvelteGanttExternal, SvelteGanttTable, MomentSvelteGanttDateAdapter } from 'svelte-gantt'; import {global, eq_category, location_type} from 'src/pages/js/static_data' import "datejs"; import { Loading } from 'quasar'

export default {
name: 'GanttChart',
data() {
return {

  gantt: null,
  company: null,
  CompanyList: [],
  location: null,
  LocationList: [],
  parents: [],
  isCusOrSup: "Supplier",
  group: 0,
  typeList: [
    'Supplier', 'Customer', 'Carrier'
  ],
  groupList: [
    {
      label: 'None',
      value: 0,

    },
    {
      label: 'Carrier',
      value: 3,

    },
    {
      label: 'Customer',
      value: 2,

    },
    {
      label: 'Customer Location',
      value: 5,

    },
    {
      label: 'Driver',
      value: 6,

    },
    {
      label: 'Supplier',
      value: 1,

    },


    {
      label: 'Supplier Location',
      value: 4,

    },


  ],
  trip_data: null,
  modified_trip: null,
  row_db: [],
  items: [],
  days: 1,
  daysList: [
    {
      label: '1 Day',
      value: 0,

    },
    {
      label: '2 Days',
      value: 1,

    },
    {
      label: '3 Days',
      value: 2,

    },
    {
      label: '7 Days',
      value: 6,

    },


  ],
  custom: false,
  selected_date: null,

  zoomLevel: 14,
  see_allGantt: false,
  columnsFromDB: [],


}

},

async created() {
this.store.typeRight = 2;

},
async mounted() {
/// let currentStart = this.$moment("add", "1 days")
//let currentEnd = this.$moment("add", "7 days")

this.selected_date = this.$moment(new Date(), 'YYYY-MM-DD');
await this.loadGant();
await this.loadData();


this.subscription = DataStore.observe(Trip).subscribe((msg) => {

})

},

methods: {
time(input) {
//console.log(input);
console.log(moment(input, 'HH:mm').unix());
return moment(input, 'HH:mm').unix();
// return this.moment(input, "DD/MM/YY");
},
async selDateFunc() {
await this.loadData();

},
async clearlocation() {

  this.location = null;
  await this.loadData();
},
async selisCusOrSup(value) {
  this.isCusOrSup = value;
  await this.loadData();

},
async selDays(value) {
  this.days = value;
  await this.loadData();
},
async selGroup(value) {
  this.group = value;
  await this.loadData();
},
async loadData() {


  Loading.show()


  Loading.hide();


},


getObjectByValue(value) {
  return this.global.TripStatus.filter(function (object) {
    return object['id'] === value;
  });
},
async visibilityChanged(isVisible, entry) {


},
// this.$refs.ganttChart
//document.getElementById("customMap2")


async loadGant() {
  const currentStart = moment().startOf('week').valueOf();
  const currentEnd = moment().endOf('week').valueOf();

  // const colors = ['blue', 'green', 'orange']


  const data = {
    rows: [{
      id: 1,
      label: "Accounting",
    }],
    tasks: [{
      id: 1,
      resourceId: 1,
      label: "PET-CT",
      from: this.time("13:30"),
      to: this.time("15:00"),
      classes: null
    }],
    dependencies: []
  }

  let options = {
    dateAdapter: new MomentSvelteGanttDateAdapter(moment),
    rows: data.rows,
    tasks: data.tasks,
    dependencies: data.dependencies,
    timeRanges: [],
    columnOffset: 15,
    magnetOffset: 15,
    rowHeight: 52,
    rowPadding: 6,
    headers: [{unit: 'day', format: 'MMMM Do'}, {unit: 'hour', format: 'H:mm'}],
    fitWidth: true,
    minWidth: 800,
    from: currentStart,
    to: currentEnd,
    tableHeaders: [{title: 'Label', property: 'label', width: 140, type: 'tree'}],
    tableWidth: 240,
    ganttTableModules: [SvelteGanttTable],
    ganttBodyModules: [SvelteGanttDependencies]
  }

//document.getElementById("ganttChart")
this.gantt = await new SvelteGantt(this.$refs.ganttChart, options);

}

},

setup() {

const store = mainStore();
return {
  store,
  global,
  eq_category,
  location_type
  //  moment


};

},
}
</script>

<style> </style>

`

I resolved my issue. It was my mistake. Thank you