I'm having some trouble getting my series points to separate by 'Category'. Visual view is attached, code and data example is below.
It looks like the last category in the list overwrites the one before it. (in this case 'comments' overwrites 'views')
Thanks for your help.
It looks like the last category in the list overwrites the one before it. (in this case 'comments' overwrites 'views')
Thanks for your help.
$transport
=
new
\Kendo\Data\DataSourceTransport();
$transport
->read(
array
(
'url'
=>
'/projects/stats/data/'
.
$id
,
'type'
=>
'POST'
,
'dataType'
=>
'json'
,
'data'
=>
array
(
'datelow'
=>
$dateLow
,
'datehigh'
=>
$dateHigh
,
'category'
=>
$category
),
));
$series
=
new
\Kendo\Dataviz\UI\ChartSeriesItem();
$series
->type(
'line'
)
->field(
'count'
)
->name(
'count'
);
//->aggregate('count');
//->groupNameTemplate('#= group.value #')
$valueAxis
=
new
\Kendo\Dataviz\UI\ChartValueAxisItem();
$valueAxis
->labels(
array
(
'format'
=>
'{0}'
,
'skip'
=> 0,
'step'
=> 2
));
$valueAxis
->min(0);
//$valueAxis->max(100);
//$valueAxis->majorUnit(10);
$categoryAxis
=
new
\Kendo\Dataviz\UI\ChartCategoryAxisItem();
$categoryAxis
->field(
'timestamp'
);
//$categoryAxis->type('date');
$tooltip
=
new
\Kendo\Dataviz\UI\ChartTooltip();
$tooltip
->visible(true)
->format(
'{0}%'
)
->color(
'#fff'
)
->template(
'#= series.name # : #= value #'
);
// Configure the model
$model
=
new
\Kendo\Data\DataSourceSchemaModel();
$model
->addField(
array
(
'field'
=>
'timestamp'
,
'type'
=>
'date'
));
$schema
=
new
\Kendo\Data\DataSourceSchema();
$schema
->model(
$model
);
$dataSource
=
new
\Kendo\Data\DataSource();
$dataSource
->error(
'function(e) { console.log(e); }'
);
$dataSource
->transport(
$transport
)
->schema(
$schema
)
->addGroupItem(
array
(
'field'
=>
'category'
));
$chart
=
new
\Kendo\Dataviz\UI\Chart(
'chart'
);
$chart
->title(
array
(
'text'
=>
'Episode Statistics'
))
->dataSource(
$dataSource
)
->legend(
array
(
'position'
=>
'bottom'
))
->addSeriesItem(
$series
)
->addValueAxisItem(
$valueAxis
)
->addCategoryAxisItem(
$categoryAxis
)
->seriesDefaults(
array
(
'type'
=>
'area'
))
->tooltip(
$tooltip
)
->transitions(false);
[
{
id: "72",
episode: "9",
user: "7",
timestamp: "2013-04-19",
category: "views",
count: 1
},
{
id: "71",
episode: "9",
user: "7",
timestamp: "2013-04-19",
category: "views",
count: 1
},
{
id: "73",
episode: "9",
user: "8",
timestamp: "2013-04-19",
category: "views",
count: 1
},
{
id: "74",
episode: "9",
user: "7",
timestamp: "2013-04-19",
category: "views",
count: 1
},
{
id: "78",
episode: "9",
user: "9",
timestamp: "2013-04-19",
category: "views",
count: 1
},
{
id: "75",
episode: "9",
user: "9",
timestamp: "2013-04-19",
category: "views",
count: 1
},
{
id: "70",
episode: "9",
user: "8",
timestamp: "2013-04-19",
category: "views",
count: 1
},
{
id: "69",
episode: "9",
user: "7",
timestamp: "2013-04-19",
category: "views",
count: 1
},
{
id: "64",
episode: "9",
user: "7",
timestamp: "2013-04-19",
category: "views",
count: 1
},
{
id: "3",
episode: "9",
user: "7",
parent: "0",
comment: "Writing another comment",
editcount: "0",
timestamp: "2013-04-19",
flagged: "0",
category: "comments",
count: 1
},
{
id: "65",
episode: "9",
user: "7",
timestamp: "2013-04-19",
category: "views",
count: 1
},
{
id: "66",
episode: "9",
user: "7",
timestamp: "2013-04-19",
category: "views",
count: 1
},
{
id: "68",
episode: "9",
user: "7",
timestamp: "2013-04-19",
category: "views",
count: 1
},
{
id: "67",
episode: "9",
user: "7",
timestamp: "2013-04-19",
category: "views",
count: 1
},
{
id: "2",
episode: "9",
user: "7",
parent: "0",
comment: "A really insightful piece.",
editcount: "0",
timestamp: "2013-04-19",
flagged: "0",
category: "comments",
count: 1
}
]