This is a migrated thread and some comments may be shown as answers.

build categoryAxis from Array and have data properly align

4 Answers 67 Views
Charts
This is a migrated thread and some comments may be shown as answers.
Cedric Gaines
Top achievements
Rank 2
Cedric Gaines asked on 15 Jun 2016, 07:23 PM

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
}

4 Answers, 1 is accepted

Sort by
0
Cedric Gaines
Top achievements
Rank 2
answered on 15 Jun 2016, 07:24 PM

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
}

0
Cedric Gaines
Top achievements
Rank 2
answered on 15 Jun 2016, 07:25 PM

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
}

0
Iliana Dyankova
Telerik team
answered on 17 Jun 2016, 03:38 PM
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.
 
0
Cedric Gaines
Top achievements
Rank 2
answered on 22 Jun 2016, 04:04 PM

AWESOME

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

Thanks a million,

Cedric

Tags
Charts
Asked by
Cedric Gaines
Top achievements
Rank 2
Answers by
Cedric Gaines
Top achievements
Rank 2
Iliana Dyankova
Telerik team
Share this question
or