build categoryAxis from Array and have data properly align

5 posts, 0 answers
  1. Cedric Gaines
    Cedric Gaines avatar
    9 posts
    Member since:
    Dec 2004

    Posted 15 Jun Link to this post

    Hello,

    I'm trying to figure out how to achieve the following.

    I have an array named chartdates which has all the unique date returns from our lookup 

    I also have deptChartObjects that has the hits array along with the hit dates

    I simply need to draw the line chart so that they correspond with the hitDate or proply fall within the chartdates.  Right now the categoryAxis doesn't show and the line draws properly, but the 3 lines basically stack on each other.  so line 1 might have say a start date of 5/1 and line 2 will have a start date of 5/5 but they both stack on top of each other.  I will the the data point for line 1 (5/1) to be before say line 2 (5/5).

    Looking for some guidence on how to achiece this.

    Thanks in advance,

    Here is a sample JSON return

    {
      "top3Departments": {},
      "departmentInfoDS": {
        "DeptStats": [
          {
            "workgrp": "ONY",
            "numberOfHits": 1972,
            "recorddate": "2016-05-12T00:00:00",
            "departmenttitle": "ANONYMOUS"
          },
          {
            "workgrp": "ONY",
            "numberOfHits": 333,
            "recorddate": "2016-05-24T00:00:00",
            "departmenttitle": "ANONYMOUS"
          },
          {
            "workgrp": "ONY",
            "numberOfHits": 224,
            "recorddate": "2016-05-25T00:00:00",
            "departmenttitle": "ANONYMOUS"
          }
        ]
      },
      "chartDates": {
        "chartdates": [
          {
            "recorddate": "2016-05-12T00:00:00"
          },
          {
            "recorddate": "2016-05-23T00:00:00"
          },
          {
            "recorddate": "2016-05-24T00:00:00"
          },
          {
            "recorddate": "2016-05-25T00:00:00"
          },
          {
            "recorddate": "2016-05-26T00:00:00"
          },
          {
            "recorddate": "2016-05-27T00:00:00"
          },
          {
            "recorddate": "2016-05-28T00:00:00"
          },
          {
            "recorddate": "2016-05-29T00:00:00"
          },
          {
            "recorddate": "2016-05-30T00:00:00"
          }
        ]
      },
      "deptChartObjects": [
        {
          "hits": [
            1972,
            333,
            224
          ],
          "hitDates": [
            "2016-05-12T00:00:00",
            "2016-05-24T00:00:00",
            "2016-05-25T00:00:00"
          ],
          "name": "ANONYMOUS"
        },
        {
          "hits": [
            1972,
            333,
            224
          ],
          "hitDates": [
            "2016-05-12T00:00:00",
            "2016-05-24T00:00:00",
            "2016-05-25T00:00:00"
          ],
          "name": "ANONYMOUS"
        },
        {
          "hits": [
            1972,
            333,
            224
          ],
          "hitDates": [
            "2016-05-12T00:00:00",
            "2016-05-24T00:00:00",
            "2016-05-25T00:00:00"
          ],
          "name": "ANONYMOUS"
        }
      ],
      "departmentID": "ONY",
      "departmentName": "ANONYMOUS",
      "fromDTStr": "05-01-2016",
      "toDTStr": "05-30-2016",
      "totalHits": 2529,
      "chartJSON": null
    }

  2. Cedric Gaines
    Cedric Gaines avatar
    9 posts
    Member since:
    Dec 2004

    Posted 15 Jun in reply to Cedric Gaines Link to this post

    Wrong JSON Feed

    Here is a real sample

    {
      "top3Departments": {
        "Top3Departments": [
          {
            "workgrp": "ONY",
            "numberOfHits": 2529,
            "departmentName": "ANONYMOUS"
          },
          {
            "workgrp": "UNKNOWN",
            "numberOfHits": 2395,
            "departmentName": "UNKNOWN"
          }
        ]
      },
      "departmentInfoDS": {
        "DeptStats": [
          {
            "workgrp": "UNKNOWN",
            "numberOfHits": 28,
            "recorddate": "2016-05-12T00:00:00",
            "departmenttitle": "UNKNOWN"
          },
          {
            "workgrp": "UNKNOWN",
            "numberOfHits": 1000,
            "recorddate": "2016-05-23T00:00:00",
            "departmenttitle": "UNKNOWN"
          },
          {
            "workgrp": "UNKNOWN",
            "numberOfHits": 669,
            "recorddate": "2016-05-24T00:00:00",
            "departmenttitle": "UNKNOWN"
          },
          {
            "workgrp": "UNKNOWN",
            "numberOfHits": 118,
            "recorddate": "2016-05-25T00:00:00",
            "departmenttitle": "UNKNOWN"
          },
          {
            "workgrp": "UNKNOWN",
            "numberOfHits": 116,
            "recorddate": "2016-05-26T00:00:00",
            "departmenttitle": "UNKNOWN"
          },
          {
            "workgrp": "UNKNOWN",
            "numberOfHits": 116,
            "recorddate": "2016-05-27T00:00:00",
            "departmenttitle": "UNKNOWN"
          },
          {
            "workgrp": "UNKNOWN",
            "numberOfHits": 116,
            "recorddate": "2016-05-28T00:00:00",
            "departmenttitle": "UNKNOWN"
          },
          {
            "workgrp": "UNKNOWN",
            "numberOfHits": 116,
            "recorddate": "2016-05-29T00:00:00",
            "departmenttitle": "UNKNOWN"
          },
          {
            "workgrp": "UNKNOWN",
            "numberOfHits": 116,
            "recorddate": "2016-05-30T00:00:00",
            "departmenttitle": "UNKNOWN"
          },
          {
            "workgrp": "ONY",
            "numberOfHits": 1972,
            "recorddate": "2016-05-12T00:00:00",
            "departmenttitle": "ANONYMOUS"
          },
          {
            "workgrp": "ONY",
            "numberOfHits": 333,
            "recorddate": "2016-05-24T00:00:00",
            "departmenttitle": "ANONYMOUS"
          },
          {
            "workgrp": "ONY",
            "numberOfHits": 224,
            "recorddate": "2016-05-25T00:00:00",
            "departmenttitle": "ANONYMOUS"
          }
        ]
      },
      "chartDates": {
        "chartdates": [
          {
            "recorddate": "2016-05-12T00:00:00"
          },
          {
            "recorddate": "2016-05-23T00:00:00"
          },
          {
            "recorddate": "2016-05-24T00:00:00"
          },
          {
            "recorddate": "2016-05-25T00:00:00"
          },
          {
            "recorddate": "2016-05-26T00:00:00"
          },
          {
            "recorddate": "2016-05-27T00:00:00"
          },
          {
            "recorddate": "2016-05-28T00:00:00"
          },
          {
            "recorddate": "2016-05-29T00:00:00"
          },
          {
            "recorddate": "2016-05-30T00:00:00"
          }
        ]
      },
      "deptChartObjects": [
        {
          "hits": [
            1972,
            333,
            224
          ],
          "hitDates": [
            "2016-05-12T00:00:00",
            "2016-05-24T00:00:00",
            "2016-05-25T00:00:00"
          ],
          "name": "ANONYMOUS"
        },
        {
          "hits": [
            28,
            1000,
            669,
            118,
            116,
            116,
            116,
            116,
            116
          ],
          "hitDates": [
            "2016-05-12T00:00:00",
            "2016-05-23T00:00:00",
            "2016-05-24T00:00:00",
            "2016-05-25T00:00:00",
            "2016-05-26T00:00:00",
            "2016-05-27T00:00:00",
            "2016-05-28T00:00:00",
            "2016-05-29T00:00:00",
            "2016-05-30T00:00:00"
          ],
          "name": "UNKNOWN"
        }
      ],
      "departmentID": "TOP3",
      "departmentName": "NOT FOUND",
      "fromDTStr": "05-01-2016",
      "toDTStr": "05-30-2016",
      "totalHits": 4924,
      "chartJSON": null
    }

  3. Kendo UI is VS 2017 Ready
  4. Cedric Gaines
    Cedric Gaines avatar
    9 posts
    Member since:
    Dec 2004

    Posted 15 Jun in reply to Cedric Gaines Link to this post

    Wrong feed

    better json sample

    {
      "top3Departments": {
        "Top3Departments": [
          {
            "workgrp": "ONY",
            "numberOfHits": 2529,
            "departmentName": "ANONYMOUS"
          },
          {
            "workgrp": "UNKNOWN",
            "numberOfHits": 2395,
            "departmentName": "UNKNOWN"
          }
        ]
      },
      "departmentInfoDS": {
        "DeptStats": [
          {
            "workgrp": "UNKNOWN",
            "numberOfHits": 28,
            "recorddate": "2016-05-12T00:00:00",
            "departmenttitle": "UNKNOWN"
          },
          {
            "workgrp": "UNKNOWN",
            "numberOfHits": 1000,
            "recorddate": "2016-05-23T00:00:00",
            "departmenttitle": "UNKNOWN"
          },
          {
            "workgrp": "UNKNOWN",
            "numberOfHits": 669,
            "recorddate": "2016-05-24T00:00:00",
            "departmenttitle": "UNKNOWN"
          },
          {
            "workgrp": "UNKNOWN",
            "numberOfHits": 118,
            "recorddate": "2016-05-25T00:00:00",
            "departmenttitle": "UNKNOWN"
          },
          {
            "workgrp": "UNKNOWN",
            "numberOfHits": 116,
            "recorddate": "2016-05-26T00:00:00",
            "departmenttitle": "UNKNOWN"
          },
          {
            "workgrp": "UNKNOWN",
            "numberOfHits": 116,
            "recorddate": "2016-05-27T00:00:00",
            "departmenttitle": "UNKNOWN"
          },
          {
            "workgrp": "UNKNOWN",
            "numberOfHits": 116,
            "recorddate": "2016-05-28T00:00:00",
            "departmenttitle": "UNKNOWN"
          },
          {
            "workgrp": "UNKNOWN",
            "numberOfHits": 116,
            "recorddate": "2016-05-29T00:00:00",
            "departmenttitle": "UNKNOWN"
          },
          {
            "workgrp": "UNKNOWN",
            "numberOfHits": 116,
            "recorddate": "2016-05-30T00:00:00",
            "departmenttitle": "UNKNOWN"
          },
          {
            "workgrp": "ONY",
            "numberOfHits": 1972,
            "recorddate": "2016-05-12T00:00:00",
            "departmenttitle": "ANONYMOUS"
          },
          {
            "workgrp": "ONY",
            "numberOfHits": 333,
            "recorddate": "2016-05-24T00:00:00",
            "departmenttitle": "ANONYMOUS"
          },
          {
            "workgrp": "ONY",
            "numberOfHits": 224,
            "recorddate": "2016-05-25T00:00:00",
            "departmenttitle": "ANONYMOUS"
          }
        ]
      },
      "chartDates": {
        "chartdates": [
          {
            "recorddate": "2016-05-12T00:00:00"
          },
          {
            "recorddate": "2016-05-23T00:00:00"
          },
          {
            "recorddate": "2016-05-24T00:00:00"
          },
          {
            "recorddate": "2016-05-25T00:00:00"
          },
          {
            "recorddate": "2016-05-26T00:00:00"
          },
          {
            "recorddate": "2016-05-27T00:00:00"
          },
          {
            "recorddate": "2016-05-28T00:00:00"
          },
          {
            "recorddate": "2016-05-29T00:00:00"
          },
          {
            "recorddate": "2016-05-30T00:00:00"
          }
        ]
      },
      "deptChartObjects": [
        {
          "hits": [
            1972,
            333,
            224
          ],
          "hitDates": [
            "2016-05-12T00:00:00",
            "2016-05-24T00:00:00",
            "2016-05-25T00:00:00"
          ],
          "name": "ANONYMOUS"
        },
        {
          "hits": [
            28,
            1000,
            669,
            118,
            116,
            116,
            116,
            116,
            116
          ],
          "hitDates": [
            "2016-05-12T00:00:00",
            "2016-05-23T00:00:00",
            "2016-05-24T00:00:00",
            "2016-05-25T00:00:00",
            "2016-05-26T00:00:00",
            "2016-05-27T00:00:00",
            "2016-05-28T00:00:00",
            "2016-05-29T00:00:00",
            "2016-05-30T00:00:00"
          ],
          "name": "UNKNOWN"
        }
      ],
      "departmentID": "TOP3",
      "departmentName": "NOT FOUND",
      "fromDTStr": "05-01-2016",
      "toDTStr": "05-30-2016",
      "totalHits": 4924,
      "chartJSON": null
    }

  5. Iliana Nikolova
    Admin
    Iliana Nikolova avatar
    2592 posts

    Posted 17 Jun Link to this post

    Hi Cedric,

    When there is a different numbers of points in each of the series you should use series.categoryField instead of categoryAxis.field (documentation link). For your convenience I prepared a dojo which demonstrates how to achieve the expected outcome by using the current data set.

    Regards,
    Iliana Nikolova
    Telerik
     
    Get started with Kendo UI in days. Online training courses help you quickly implement components into your apps.
     
  6. Cedric Gaines
    Cedric Gaines avatar
    9 posts
    Member since:
    Dec 2004

    Posted 22 Jun in reply to Iliana Nikolova Link to this post

    AWESOME

    This helped me ALOT.  I was able to finish what I was working on.

    Thanks a million,

    Cedric

Back to Top
Kendo UI is VS 2017 Ready