Announcement

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

    Time-part in Date items in Graph

    Please take look at the attachment. The "12:00" part is being displayed although in the docs I read:
    "A logical date, with no time value (such as a holiday or birthday). Represented on the client as a JavaScript Date object where time values are ignored. See DateFormatAndStorage for more information on date display and serialization formats. "
    https://www.smartclient.com/smartgwt...Type.html#DATE

    Then: " Fields of type date are considered to be logical Dates with no time value, such as a holiday or birthday. In the browser, values for "date" fields are stored as Date objects, but when formatted for display to the user, they are typically displayed without any time information. " (https://www.smartclient.com/smartgwt...ndStorage.html).

    So why are the time-values being displayed in the charts? Any way to avoid this ?
    Using smartgwt 5.0 10.03.16 power Click image for larger version

Name:	Bildschirmfoto 2016-03-10 um 14.18.34.png
Views:	143
Size:	100.0 KB
ID:	235717

    #2
    We've made a few changes to improve handling of logical dates in FacetChart axes, and that may resolve your issue. They've been applied to SGWT 5.0p/SC 10.0p and newer and will be in the nightly builds dated 2016-03-16 and newer.

    If your issue persists, we'll need repro code to go any further. See "Preparing a standalone test case" in our SmartGWT documentation.

    Comment


      #3
      This seems to be corrected in the 20.03 build, thanks

      Comment


        #4
        Did you also correct this on the 5.1p branch?
        I see this problem again with 5.1-p20160327 power.

        Comment


          #5
          This was committed to 5.1p as well, on the same date (March 16th).

          Comment


            #6
            Please open your own testcase:
            http://www.smartclient.com/smartgwte...tockPricesZoom

            Then make the zoom area so small as possible, and you will see:
            00:00:00 Click image for larger version

Name:	Bildschirmfoto 2016-03-31 um 02.45.54.png
Views:	132
Size:	282.2 KB
ID:	236369

            Comment


              #7
              This looks to be an example issue - the example involves a custom DataSource that directly parses CSV, and it uses new Date() to construct Date instances, whereas the correct technique would be to call DateUtil.createLogicalDate(). We'll update the sample code, but again the FacetChart already has the changes you're looking for.

              Comment


                #8
                I am not using CSV or new Date() or something similar. I just have a SQL Datasource with a field of type "date", which is showing the 00:00:00 part when making the zoom area small, just as in the example.

                Despite of this, in your example, the StockPricesDataSource.java has a field: new DataSourceField("date", FieldType.DATE, "Date")
                In your docs, I read:
                Code:
                Fields of type [URL="https://www.smartclient.com/smartgwt/javadoc/com/smartgwt/client/types/FieldType.html"]date[/URL] are considered to be logical Dates with no time value, such as a holiday or birthday.
                In the browser, values for "date" fields are stored as Date objects, but when formatted for display to the user,
                they are typically displayed without any time information. " ([URL="https://www.smartclient.com/smartgwt/javadoc/com/smartgwt/client/docs/DateFormatAndStorage.html"]https://www.smartclient.com/smartgwt...ndStorage.html[/URL]).
                Then, according to your docs, fields of type date are formatted without any time information in the browser. No matter how you create these dates, if you pass them to the datasource, they are of type "date", which, according to your docs, should not show any time information. Or what is wrong here?

                Comment


                  #9
                  If I change in your sample:

                  StockPricesDataSource.java:
                  Code:
                  record.setAttribute(fieldName, new Date(year, month - 1, day));  ;
                  to
                  Code:
                  record.setAttribute(fieldName, DateUtil.createLogicalDate(year, month-1, day));
                  I get 06.09.106 ? This is not a date. What is this? Click image for larger version

Name:	Bildschirmfoto 2016-03-31 um 15.15.38.png
Views:	133
Size:	133.0 KB
ID:	236388

                  Comment


                    #10
                    And 104 , 105, 106 instead of a year. Click image for larger version

Name:	Bildschirmfoto 2016-03-31 um 15.17.01.png
Views:	134
Size:	64.4 KB
ID:	236390

                    Comment


                      #11
                      If you look just 3 lines above where "new Date()" is called in the original code, you'll see that the "year" variable is an offset from 1900, which is required by that constructor. In contrast, DateUtil.createLogicalDate() requires the actual year.

                      Comment


                        #12
                        you are right. I corrected this.
                        But you didn't answer my question: the datasource has a field of type "date", and according to your docs, fields of type "date" are presented to the browser without the time part (no matter how you create these instances?). So even with "new Date()" the time part should not be presented in the browser according your docs.

                        Originally posted by edulid View Post
                        I am not using CSV or new Date() or something similar. I just have a SQL Datasource with a field of type "date", which is showing the 00:00:00 part when making the zoom area small, just as in the example.

                        Despite of this, in your example, the StockPricesDataSource.java has a field: new DataSourceField("date", FieldType.DATE, "Date")
                        In your docs, I read:
                        Code:
                        Fields of type [URL="https://www.smartclient.com/smartgwt/javadoc/com/smartgwt/client/types/FieldType.html"]date[/URL] are considered to be logical Dates with no time value, such as a holiday or birthday.
                        In the browser, values for "date" fields are stored as Date objects, but when formatted for display to the user,
                        they are typically displayed without any time information. " ([URL="https://www.smartclient.com/smartgwt/javadoc/com/smartgwt/client/docs/DateFormatAndStorage.html"]https://www.smartclient.com/smartgwt...ndStorage.html[/URL]).
                        Then, according to your docs, fields of type date are formatted without any time information in the browser. No matter how you create these dates, if you pass them to the datasource, they are of type "date", which, according to your docs, should not show any time information. Or what is wrong here?

                        Comment


                          #13
                          The docs are correct here and it's not clear what your question is..

                          Perhaps you haven't realized that the FacetChart does not have your DataSource? It just has the data derived from the DataSource. If the Date objects it receives are created by code that manually parses a CSV and uses "new Date()" to construct the Date instances, there is no way for them to end up as specially marked LogicalDate instances.

                          You mentioned you are using a SQL DataSource. Unless you've added code similar to the sample, you should already be getting LogicalDate instances. If you aren't, you haven't shown us any way to reproduce your issue.

                          Comment


                            #14
                            The sample code has been updated. Please try the next nightly build, dated April 5.

                            Regards
                            Isomorphic Software

                            Comment


                              #15
                              Here you can see the problem with the time-part:

                              Entrypoint:
                              Code:
                              public void onModuleLoad() {
                              
                                      final VLayout vlayout = new VLayout();
                              
                                      chart = new FacetChart();
                                      chart.setChartType(ChartType.LINE);
                                      chart.setStacked(Boolean.FALSE);
                                      chart.setLabelCollapseMode(LabelCollapseMode.TIME);
                                      chart.setMinLabelGap(4);
                                      chart.setRotateLabels(LabelRotationMode.NEVER);
                              
                                      chart.setCanZoom(true);
                                      FacetChart zoomChartProperties = new FacetChart();
                                      zoomChartProperties.setBackgroundColor("#e6f7ff");
                                      chart.setZoomSelectionChartProperties(zoomChartProperties);
                              
                                      chart.setFacets(new Facet("f_date", "date"), new Facet("f_val", "value"));
                                      chart.setValueProperty("f_val");
                                      
                                      DataSource.get("testingTable").fetchData(null, new DSCallback() {
                                          
                                          @Override
                                          public void execute(DSResponse dsResponse, Object data, DSRequest dsRequest) {
                                              chart.setData(dsResponse.getData());
                                          }
                                      });
                              
                                      vlayout.addMember(chart);
                                      vlayout.setWidth100();
                                      vlayout.setHeight100();
                                      vlayout.draw();
                              
                                  }
                              testing_table.ds.xml:
                              Code:
                              <DataSource ID="testingTable" serverType="sql" tableName="t_testing_table" autoDeriveSchema="true" />
                              t_testing_table definition (MSSQL, Standard attributes):
                              Code:
                              CREATE TABLE [dbo].[t_testing_table](
                                  [f_id] [int] IDENTITY(1,1) NOT NULL,
                                  [f_date] [datetime2](7) NOT NULL,
                                  [f_val] [decimal](20, 5) NOT NULL,
                               CONSTRAINT [PK_t_testing_table] PRIMARY KEY CLUSTERED
                              (
                                  [f_id] ASC
                              )WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
                              ) ON [PRIMARY]
                              Data:
                              Code:
                              insert into t_testing_table (f_date, f_val) values ('2015-04-01', 49);
                              insert into t_testing_table (f_date, f_val) values ('2015-04-10', 77);
                              Using smartgwt 5.1p power 20160327
                              Screenshot: Click image for larger version

Name:	Bildschirmfoto 2016-04-06 um 13.53.51.png
Views:	122
Size:	41.3 KB
ID:	236579
                              Last edited by edulid; 6 Apr 2016, 04:00.

                              Comment

                              Working...
                              X