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

how to adjust area chart for non records?

1 Answer 25 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
toy
Top achievements
Rank 1
toy asked on 21 May 2013, 12:53 AM
hi 
i have a dataSource that spits out data like this:
[{
Amount: "2140402000"
MDetail: "Budget"
Month: "Jan"
Monthnum: "1"
Year: "2013"
},
{
Amount: "2146823206"
MDetail: "Budget"
Month: "Feb"
Monthnum: "2"
Year: "2013"
},
{
Amount: "2257798847"
MDetail: "Projected"
Month: "Jun"
Monthnum: "6"
Year: "2013"
},
{
Amount: "2272474540"
MDetail: "Projected"
Month: "Jul"
Monthnum: "7"
Year: "2013"
}]

and the chart markup looks like htis
$J("#chart").kendoChart({
    dataSource: {
        data:source,
        group: {
            field: "MDetail",
            dir: "asc"
        },
        sort: [
            {field: "Year", dir: "asc"},
            {field: "Monthnum", dir: "asc"}
        ]
    },
    theme: "blueOpal",
    title: {
        text: "Total Cost of Workforce for " + year
    },
    legend: {
        position: "bottom"
    },
    seriesDefaults: {
        type: "area",
        format: "${0:0,000}"
    },
    series: [{
        field: "Amount",
        groupNameTemplate: "#= group.value # "
    }],
    valueAxis: {
        labels: {
            template: "#= kendo.format('$ {0:N0}', value / 1000000) # M"
        },
        majorUnit: 100000000,
        line: {
            visible: false
        },
        axisCrossingValue: -10
    },
    categoryAxis: {
        field: "Month",
        majorGridLines: {
            visible: false
        }
    },
    tooltip: {
        visible: true,
        format: "$ {0:0,000}"
    }
});


after feb - the 'budget' MDetail falls off to 0
and before jun - i dont know what the 'projected' MDetail does
its drawing a bunch of stuff

what im trying to achieve here is:
if there are no records for anything after feb
then dont draw anything - just cut it off 
ie dont descend to 0

and likewise if there are no records for the beginning
then dont draw anything until theres a record for the category 
ie it iwll be blank until jun and then the 'projected' numbers start drawing

how do i do this?

thanksa!

1 Answer, 1 is accepted

Sort by
0
Iliana Dyankova
Telerik team
answered on 21 May 2013, 11:04 AM
Hello Toy,

I already replied to the same question in your support ticket, however I am pasting my reply here too: 

I am not quite sure if I understand your scenario correctly. Could you please elaborate a bit more on the exact outcome you are expecting? This way I would be able to advice you further and provide concrete recommendations.

On a side note, have in mind the following points: 

  • In a grouped chart the categoryAxis's labels are created depending on the first group. I.e. with the provided configuration on the categoryAxis will be displayed the "Month" for "Budget" group;
  • Categorical charts (area, column, bar etc.) require a matching set of data points (the value can benull but the record need to be presented in the data). This is due to the fact that series.data is anarray

Also, I observed that in data array the "Amount" field contains string values while the Chart expectsnumber.


Kind regards,
Iliana Nikolova
the Telerik team
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
Tags
General Discussions
Asked by
toy
Top achievements
Rank 1
Answers by
Iliana Dyankova
Telerik team
Share this question
or