Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
Clear All
new posts

    Wrong (too small) rendered height of events in Timeline

    Smart GWT 4.0p (2013-08-19)

    Ran into this problem yesterday. Please see attached screen shots (a second has been added to show how it appears in production environment). The overlapped events cause the event height to small, and the lane seems like a "waterfall model" instead optimized filled blocks on the grid.

    Here is the code to repeat:

    Code:
    public class TestTimelineRenderingProblemWhenHasOverBookedEvents implements EntryPoint {
    	
    	private static Date today = new Date();   
    	private static int year = today.getYear();   
    	private static int month = today.getMonth();   
    	private static int day = today.getDate() - today.getDay();   	
    
    	@Override
    	public void onModuleLoad() {
        	Timeline timeline = new Timeline();
        
        	timeline.setEventSnapGap(25);
    
        	timeline.setCanResizeTimelineEvents(false);   
        	timeline.setCanEditLane(false);   
        	timeline.setShowEventDescriptions(false); 
        	timeline.setDefaultTimelineColumnSpan(1);
        	timeline.setTimelineUnitsPerColumn(1);
        	timeline.setColumnsPerPage(24); 
        	timeline.setTimeFormatter(TimeDisplayFormat.TOSHORTTIME);
        	
        	timeline.setShowWeekends(false);
    		timeline.setWorkdays(new int[]{1,2,3,4,5,6});
    		timeline.setFirstDayOfWeek(1); // Monday
    		
    		timeline.setSaveButtonTitle("Start Request");
    		timeline.setEventNameFieldTitle("Request Comment");
    		timeline.setDateEditingStyle(DateEditingStyle.DATETIME);
    		
    		timeline.setEventLaneFieldTitle("Room");
    		
    		String[] hours = new String[] {
    				"6:00am",
    				"7:00am",
    				"8:00am",
    				"9:00am",
    				"10:00am",
    				"11:00am",
    				"12:00pm",
    				"1:00pm",
    				"2:00pm",
    				"3:00pm",
    				"4:00pm",
    				"5:00pm",
    				"6:00pm",
    				"7:00pm",
    				"8:00pm"};
    		
        	HeaderLevel hlHour = new HeaderLevel(TimeUnit.HOUR, hours);
        	hlHour.setHeaderWidth(100);
            HeaderLevel[] headerLevels = new HeaderLevel[]{   
                   hlHour   
            };   
            timeline.setHeaderLevels(headerLevels);
            
            ListGridField lgfLaneHeader = new ListGridField("title", "Room / Time");
            timeline.setLaneFields(lgfLaneHeader);
            
            SortSpecifier[] overlapSortSpecifiers = { 
    				new SortSpecifier("order", SortDirection.DESCENDING), 
    				new SortSpecifier("startDate", SortDirection.ASCENDING)};
            
            timeline.setOverlapSortSpecifiers(overlapSortSpecifiers);
    		
    		timeline.setLanes(getLanes());
    		long t = System.currentTimeMillis();
    		timeline.setData(getEvents());
    		System.out.println("set events: " + (System.currentTimeMillis() - t) + " ms");
    		
    		Date startDate = new Date(year, month, day, 6, 0, 0);
    		Date endDate = new Date(year, month, day, 16, 0, 0);
    		timeline.setTimelineRange(startDate, endDate);
    
    		timeline.draw();
    	}
    	
    	public static Lane[] getLanes() {
    		Lane[] lanes = new Lane[]{
    				new Lane("ln 1", "ln 1"),
    				};
    		
    		for(Lane lane : lanes) {
    			lane.setHeight(500);
    		}
    		
    		return lanes;
    	}
    	
    	public static CalendarEvent[] getEvents() {
    		CalendarEvent[] events = new CalendarEvent[20];
    		events[0] = new CalendarEvent(35, "#35", "", new Date(year, month, day, 8, 0, 0), new Date(year, month, day, 8, 29, 59), "ln 1");
    		events[0].setAttribute("order", 2);
    		events[1] = new CalendarEvent(36, "#36", "", new Date(year, month, day, 7, 30, 0), new Date(year, month, day, 7, 59, 59), "ln 1");
    		events[1].setAttribute("order", 2);
    		events[2] = new CalendarEvent(37, "#37", "", new Date(year, month, day, 7, 0, 0), new Date(year, month, day, 7, 29, 59), "ln 1");
    		events[2].setAttribute("order", 2);
    		events[3] = new CalendarEvent(38, "#38", "", new Date(year, month, day, 8, 0, 0), new Date(year, month, day, 8, 29, 59), "ln 1");
    		events[3].setAttribute("order", 2);
    		events[4] = new CalendarEvent(39, "#39", "", new Date(year, month, day, 8, 0, 0), new Date(year, month, day, 8, 29, 59), "ln 1");
    		events[4].setAttribute("order", 2);
    		events[5] = new CalendarEvent(40, "#40", "", new Date(year, month, day, 8, 30, 0), new Date(year, month, day, 8, 59, 59), "ln 1");
    		events[5].setAttribute("order", 2);
    		events[6] = new CalendarEvent(41, "#41", "", new Date(year, month, day, 9, 0, 0), new Date(year, month, day, 9, 29, 59), "ln 1");
    		events[6].setAttribute("order", 2);
    		events[7] = new CalendarEvent(42, "#42", "", new Date(year, month, day, 9, 0, 0), new Date(year, month, day, 9, 29, 59), "ln 1");
    		events[7].setAttribute("order", 2);
    		events[8] = new CalendarEvent(43, "#43", "", new Date(year, month, day, 9, 30, 0), new Date(year, month, day, 9, 59, 59), "ln 1");
    		events[8].setAttribute("order", 2);
    		events[9] = new CalendarEvent(44, "#44", "", new Date(year, month, day, 10, 0, 0), new Date(year, month, day, 10, 29, 59), "ln 1");
    		events[9].setAttribute("order", 2);
    		events[10] = new CalendarEvent(45, "#45", "", new Date(year, month, day, 10, 30, 0), new Date(year, month, day, 10, 59, 59), "ln 1");
    		events[10].setAttribute("order", 2);
    		events[11] = new CalendarEvent(46, "#46", "", new Date(year, month, day, 12, 0, 0), new Date(year, month, day, 12, 29, 59), "ln 1");
    		events[11].setAttribute("order", 2);
    		events[12] = new CalendarEvent(47, "#47", "", new Date(year, month, day, 7, 30, 0), new Date(year, month, day, 7, 59, 59), "ln 1");
    		events[12].setAttribute("order", 2);
    		events[13] = new CalendarEvent(48, "#48", "", new Date(year, month, day, 7, 0, 0), new Date(year, month, day, 7, 29, 59), "ln 1");
    		events[13].setAttribute("order", 2);
    		events[14] = new CalendarEvent(49, "#49", "", new Date(year, month, day, 7, 30, 0), new Date(year, month, day, 7, 59, 59), "ln 1");
    		events[14].setAttribute("order", 2);
    		events[15] = new CalendarEvent(51, "#51", "", new Date(year, month, day, 8, 30, 0), new Date(year, month, day, 8, 59, 59), "ln 1");
    		events[15].setAttribute("order", 2);
    		events[16] = new CalendarEvent(52, "#52", "", new Date(year, month, day, 8, 30, 0), new Date(year, month, day, 8, 59, 59), "ln 1");
    		events[16].setAttribute("order", 2);
    		events[17] = new CalendarEvent(53, "#53", "", new Date(year, month, day, 9, 0, 0), new Date(year, month, day, 9, 29, 59), "ln 1");
    		events[17].setAttribute("order", 2);
    		events[18] = new CalendarEvent(54, "#54", "", new Date(year, month, day, 10, 0, 0), new Date(year, month, day, 10, 29, 59), "ln 1");
    		events[18].setAttribute("order", 2);
    		events[19] = new CalendarEvent(58, "#58", "", new Date(year, month, day, 7, 0, 0), new Date(year, month, day, 15, 30, 0), "ln 1");
    		events[19].setAttribute("order", 6);	
    		return events;
    	}
    }
    It seems the longer event (#58) causes the problem.

    Please note OverlapSortSpecifiers are given.
    /* the layout is even worst (one event on the top of the others) if there are no overlap sort specifiers, and you may want to fix that case as well */

    It looks like a bug, please let me know. Thank you.
    Attached Files
    Last edited by miskolczi.peter; 24 Aug 2013, 02:16.

    #2
    Just letting you know that we see this effect and someone is looking into it - we'll update here when its been fixed

    Comment


      #3
      Thank you for the update, looking for the fix.

      Comment


        #4
        Do you have any information when a fix can be expected? Thanks.

        Comment


          #5
          We're looking at it right now

          Comment


            #6
            We've made changes that should much improve event rendering in this scenario - please retest with a build dated September 13 or later.

            Comment


              #7
              Smart GWT 4.0p (2013-09-17)

              Thank you. The rendering seems to be good, if we don't get an error causes nothing is visible on the grid.

              The following error occurs with the events in the example added below:

              Code:
              com.google.gwt.core.client.JavaScriptException: (TypeError) @com.google.gwt.core.client.impl.Impl::apply(Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;)([JavaScript object(856), JavaScript object(5), JavaScript object(858)]): Unable to set property 'totalSlots' of undefined or null reference
                  at com.google.gwt.dev.shell.BrowserChannelServer.invokeJavascript(BrowserChannelServer.java:249)
                  at com.google.gwt.dev.shell.ModuleSpaceOOPHM.doInvoke(ModuleSpaceOOPHM.java:136)
                  at com.google.gwt.dev.shell.ModuleSpace.invokeNative(ModuleSpace.java:571)
                  at com.google.gwt.dev.shell.ModuleSpace.invokeNativeObject(ModuleSpace.java:279)
                  at com.google.gwt.dev.shell.JavaScriptHost.invokeNativeObject(JavaScriptHost.java:91)
                  at com.google.gwt.core.client.impl.Impl.apply(Impl.java)
                  at com.google.gwt.core.client.impl.Impl.entry0(Impl.java:242)
                  at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
                  at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
                  at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
                  at java.lang.reflect.Method.invoke(Method.java:606)
                  at com.google.gwt.dev.shell.MethodAdaptor.invoke(MethodAdaptor.java:103)
                  at com.google.gwt.dev.shell.MethodDispatch.invoke(MethodDispatch.java:71)
                  at com.google.gwt.dev.shell.OophmSessionHandler.invoke(OophmSessionHandler.java:172)
                  at com.google.gwt.dev.shell.BrowserChannelServer.reactToMessages(BrowserChannelServer.java:293)
                  at com.google.gwt.dev.shell.BrowserChannelServer.processConnection(BrowserChannelServer.java:547)
                  at com.google.gwt.dev.shell.BrowserChannelServer.run(BrowserChannelServer.java:364)
                  at java.lang.Thread.run(Thread.java:724)
              And the example code is:
              Code:
              import java.util.ArrayList;
              import java.util.Date;
              import java.util.List;
              
              import com.google.gwt.core.client.EntryPoint;
              import com.google.gwt.core.client.Scheduler;
              import com.google.gwt.core.client.Scheduler.RepeatingCommand;
              import com.smartgwt.client.data.SortSpecifier;
              import com.smartgwt.client.types.DateEditingStyle;
              import com.smartgwt.client.types.SortDirection;
              import com.smartgwt.client.types.TimeDisplayFormat;
              import com.smartgwt.client.types.TimeUnit;
              import com.smartgwt.client.widgets.calendar.CalendarEvent;
              import com.smartgwt.client.widgets.calendar.HeaderLevel;
              import com.smartgwt.client.widgets.calendar.Lane;
              import com.smartgwt.client.widgets.calendar.Timeline;
              import com.smartgwt.client.widgets.grid.ListGridField;
              
              public class TestTimelineErrorIfHasOverBookedEvents implements EntryPoint {
              	
              	private static Date today = new Date();   
              	private static int year = today.getYear();   
              	private static int month = today.getMonth();   
              	private static int day = today.getDate() - today.getDay();
              	
              	private Timeline timeline;
              
              	@Override
              	public void onModuleLoad() {
                  	timeline = new Timeline();
                  
                  	timeline.setEventSnapGap(25);
              
                  	timeline.setCanResizeTimelineEvents(false);   
                  	timeline.setCanEditLane(false);   
                  	timeline.setShowEventDescriptions(false); 
                  	timeline.setDefaultTimelineColumnSpan(1);
                  	timeline.setTimelineUnitsPerColumn(1);
                  	timeline.setColumnsPerPage(24); 
                  	timeline.setTimeFormatter(TimeDisplayFormat.TOSHORTTIME);
                  	
                  	timeline.setShowWeekends(false);
              		timeline.setWorkdays(new int[]{1,2,3,4,5,6});
              		timeline.setFirstDayOfWeek(1); // Monday
              		
              		timeline.setSaveButtonTitle("Start Request");
              		timeline.setEventNameFieldTitle("Request Comment");
              		timeline.setDateEditingStyle(DateEditingStyle.DATETIME);
              		
              		timeline.setEventLaneFieldTitle("Room");
              		
              		String[] hours = new String[] {
              				"6:00am",
              				"7:00am",
              				"8:00am",
              				"9:00am",
              				"10:00am",
              				"11:00am",
              				"12:00pm",
              				"1:00pm",
              				"2:00pm",
              				"3:00pm",
              				"4:00pm",
              				"5:00pm",
              				"6:00pm",
              				"7:00pm",
              				"8:00pm"};
              		
                  	HeaderLevel hlHour = new HeaderLevel(TimeUnit.HOUR, hours);
                  	hlHour.setHeaderWidth(100);
                      HeaderLevel[] headerLevels = new HeaderLevel[]{   
                             hlHour   
                      };   
                      timeline.setHeaderLevels(headerLevels);
                      
                      ListGridField lgfLaneHeader = new ListGridField("title", "Room / Time");
                      timeline.setLaneFields(lgfLaneHeader);
                      
                      SortSpecifier[] overlapSortSpecifiers = { 
              				new SortSpecifier("order", SortDirection.DESCENDING), 
              				new SortSpecifier("startDate", SortDirection.ASCENDING)};
                      
                      timeline.setOverlapSortSpecifiers(overlapSortSpecifiers);
              		
              
              		timeline.draw();
              		
              		Scheduler.get().scheduleFixedDelay(new RepeatingCommand() {
              			
              			@Override
              			public boolean execute() {
              				setDataForTimeline();
              				return false;
              			}
              		}, 1000);
              	}
              	
              	private void setDataForTimeline() {
              		timeline.setLanes(getLanes());
              		long t = System.currentTimeMillis();
              		timeline.setData(getEvents());
              		System.out.println("set events: " + (System.currentTimeMillis() - t) + " ms");
              		
              		Date startDate = new Date(year, month, day, 6, 0, 0);
              		Date endDate = new Date(year, month, day, 16, 0, 0);
              		timeline.setTimelineRange(startDate, endDate);
              	}
              	
              	public static Lane[] getLanes() {
              		Lane[] lanes = new Lane[]{
              				new Lane("ln 1", "ln 1"),
              				new Lane("ln 2", "ln 2"),
              				new Lane("ln 3", "ln 3"),
              				new Lane("ln 4", "ln 4"),
              				new Lane("ln 5", "ln 5")
              				};
              		
              		for(Lane lane : lanes) {
              			lane.setHeight(90);
              		}
              		
              		return lanes;
              	}
              	
              	public static CalendarEvent[] getEvents() {
              		List<CalendarEvent> eventList = new ArrayList<CalendarEvent>();
              		CalendarEvent event;
              			event = new CalendarEvent(1, "#1", "", new Date(year, month, day, 12, 30, 0), new Date(year, month, day, 14, 0, 0), "ln 3");
              			event.setAttribute("order", 0);
              			eventList.add(event);
              	
              			event = new CalendarEvent(2, "#2", "", new Date(year, month, day, 14, 45, 0), new Date(year, month, day, 16, 0, 0), "ln 3");
              			event.setAttribute("order", 0);
              			eventList.add(event);
              	
              			event = new CalendarEvent(3, "#3", "", new Date(year, month, day, 10, 0, 0), new Date(year, month, day, 10, 15, 0), "ln 2");
              			event.setAttribute("order", 0);
              			eventList.add(event);
              	
              			event = new CalendarEvent(4, "#4", "", new Date(year, month, day, 7, 30, 0), new Date(year, month, day, 9, 0, 0), "ln 4");
              			event.setAttribute("order", 0);
              			eventList.add(event);
              	
              			event = new CalendarEvent(5, "#5", "", new Date(year, month, day, 9, 30, 0), new Date(year, month, day, 10, 30, 0), "ln 4");
              			event.setAttribute("order", 0);
              			eventList.add(event);
              	
              			event = new CalendarEvent(6, "#6", "", new Date(year, month, day, 8, 0, 0), new Date(year, month, day, 8, 30, 0), "ln 3");
              			event.setAttribute("order", 0);
              			eventList.add(event);
              	
              			event = new CalendarEvent(7, "#7", "", new Date(year, month, day, 12, 0, 0), new Date(year, month, day, 12, 30, 0), "ln 3");
              			event.setAttribute("order", 1);
              			eventList.add(event);
              	
              			event = new CalendarEvent(8, "#8", "", new Date(year, month, day, 9, 0, 0), new Date(year, month, day, 9, 30, 0), "ln 2");
              			event.setAttribute("order", 2);
              			eventList.add(event);
              	
              			event = new CalendarEvent(9, "#9", "", new Date(year, month, day, 12, 30, 0), new Date(year, month, day, 13, 0, 0), "ln 2");
              			event.setAttribute("order", 2);
              			eventList.add(event);
              	
              			event = new CalendarEvent(10, "#10", "", new Date(year, month, day, 9, 30, 0), new Date(year, month, day, 10, 0, 0), "ln 1");
              			event.setAttribute("order", 2);
              			eventList.add(event);
              	
              			event = new CalendarEvent(11, "#11", "", new Date(year, month, day, 9, 15, 0), new Date(year, month, day, 9, 30, 0), "ln 2");
              			event.setAttribute("order", 3);
              			eventList.add(event);
              	
              			event = new CalendarEvent(12, "#12", "", new Date(year, month, day, 6, 0, 0), new Date(year, month, day, 6, 15, 0), "ln 4");
              			event.setAttribute("order", 4);
              			eventList.add(event);
              	
              			event = new CalendarEvent(13, "#13", "", new Date(year, month, day, 13, 30, 0), new Date(year, month, day, 14, 0, 0), "ln 4");
              			event.setAttribute("order", 4);
              			eventList.add(event);
              	
              			event = new CalendarEvent(14, "#14", "", new Date(year, month, day, 11, 45, 0), new Date(year, month, day, 12, 15, 0), "ln 4");
              			event.setAttribute("order", 4);
              			eventList.add(event);
              	
              			event = new CalendarEvent(15, "#15", "", new Date(year, month, day, 7, 0, 0), new Date(year, month, day, 13, 0, 0), "ln 3");
              			event.setAttribute("order", 5);
              			eventList.add(event);
              	
              			event = new CalendarEvent(16, "#16", "", new Date(year, month, day, 12, 0, 0), new Date(year, month, day, 16, 0, 0), "ln 1");
              			event.setAttribute("order", 6);
              			eventList.add(event);
              	
              			event = new CalendarEvent(17, "#17", "", new Date(year, month, day, 13, 0, 0), new Date(year, month, day, 17, 0, 0), "ln 3");
              			event.setAttribute("order", 6);
              			eventList.add(event);
              	
              			event = new CalendarEvent(18, "#18", "", new Date(year, month, day, 7, 0, 0), new Date(year, month, day, 12, 0, 0), "ln 4");
              			event.setAttribute("order", 6);
              			eventList.add(event);
              	
              			event = new CalendarEvent(19, "#19", "", new Date(year, month, day, 14, 0, 0), new Date(year, month, day, 17, 0, 0), "ln 4");
              			event.setAttribute("order", 6);
              			eventList.add(event);
              	
              			event = new CalendarEvent(20, "#20", "", new Date(year, month, day, 7, 0, 0), new Date(year, month, day, 15, 0, 0), "ln 2");
              			event.setAttribute("order", 6);
              			eventList.add(event);
              
              		CalendarEvent[] events = new CalendarEvent[eventList.size()];
              		eventList.toArray(events);		
              		return events;
              	}
              }
              This issue is also related to the OverlapSortSpecifiers.

              Thank you for your help.
              Last edited by miskolczi.peter; 18 Sep 2013, 11:06.

              Comment


                #8
                Could you take a look and repeat the problem detailed in #7?

                Comment


                  #9
                  Yes, it was fixed the day it was reported, or shortly afterward

                  Comment


                    #10
                    Please see the new problem detailed in #7. (it is not the original one)

                    Do you need me to enter a new thread with that (#7) ?

                    Comment


                      #11
                      No - that bug should already be fixed, as of the build from September 21

                      Comment


                        #12
                        Fixed

                        Thank you. Checked it now and it is working great with the latest code.

                        Comment

                        Working...
                        X