I've been trying to use chart and sparkline.
I have a few questions:
1) I've read in the forum that there should be no difference between the two except visual differences (http://www.telerik.com/forums/sparkline-vs-chart-efficiency-).
This doesn't seem to be the case: http://plnkr.co/edit/12gvS94rPTrR7t35wCCH?p=preview
I've created a chart (http://plnkr.co/edit/12gvS94rPTrR7t35wCCH?p=preview) and then a sparkLine (http://plnkr.co/edit/6LRb16QIgUuoWAbxLuyq?p=preview) with the same configuration (same datasource and same options file) and it gives an error when creating the sparkline but not when creating the chart.
2) How can I get the "sparkLine" effect in a "chart", or if it's easier, how to make the "sparkLine" look as good as a chart?
3) I've read these posts:
http://www.telerik.com/forums/get-chart-coordinates-for-mouse-position
http://www.telerik.com/forums/mouse-position---data---position-are-not-the-same-values
They show how to get mouse position in Silverlight and WPF.
How can I get the mouse coordinates using javascript/jQuery?
Thanks
<!DOCTYPE html>
<
html
>
<
head
>
<
title
>Test</
title
>
<
script
src
=
"scripts/jquery.min.js"
></
script
>
<!--
* Kendo UI Complete v2014.1.318 (http://kendoui.com)
* Copyright 2014 Telerik AD. All rights reserved.
-->
<
script
src
=
"scripts/kendo.all.min.js"
></
script
>
<!--
* Kendo UI Complete v2014.1.318 (http://kendoui.com)
* Copyright 2014 Telerik AD. All rights reserved.
*
-->
<
script
src
=
"scripts/kendo.dataviz.min.js"
></
script
>
<
style
>
.k-sparkline span{
font-size: 100px;
}
</
style
>
</
head
>
<
body
>
<
span
id
=
"spark"
></
span
>
<
script
type
=
"text/javascript"
>
jQuery(document).ready(function () {
jQuery("#spark").kendoSparkline({
type: "column",
data: [
16, 17, 18, 19, 20, 21, 21, 22, 23, 22,
20, 18, 17, 17, 16, 16, 17, 18, 19, 20,
21, 22, 23, 25, 24, 24, 22, 22, 23, 22,
22, 21, 16, 15, 15, 16, 19, 20, 20, 21
]
});
});
</
script
>
</
body
>
</
html
>
$(
"#sparkQtyVehicles"
).kendoSparkline({
series: [{
name:
"QtyVehicles"
,
aggregate:
"avg"
,
type:
"column"
,
field:
"QtyVehicles"
}],
categoryAxis: {
type:
"date"
,
baseUnit:
"months"
,
field:
"Date"
},
tooltip: {
visible:
true
,
shared:
false
,
template: $(
'#sparkQtyVehiclesTemplate'
).html()
},
theme:
"bootstrap"
});
01.
createChart:
function
(e) {
02.
var
list = e.sender;
03.
var
data = list.dataSource.data();
04.
for
(
var
i = 0; i < data.length; i++) {
05.
var
item = list.wrapper.find(
"[data-uid='"
+ data[i].uid +
"']"
);
06.
var
chart = item.find(
".chart"
);
07.
var
metric = data[i];
08.
this
.metrics[data[i].uid] = metric.MetricType;
09.
chart.kendoSparkline({
10.
type:
"column"
,
11.
dataSource:
new
kendo.data.DataSource({
12.
transport: {
13.
read: {
14.
url: metric.MonthService,
15.
dataType:
"json"
16.
},
17.
parameterMap:
function
(options, operation) {
18.
if
(operation ===
"read"
) {
19.
options.hotelId = 2;
// _model.get('hotelId');
20.
options.year = 2013;
//_model.get('date').getYear() + 1900;
21.
options.month = 7;
//_model.get('date').getMonth() + 1;
22.
return
options;
23.
}
24.
return
options;
25.
}
26.
}
27.
}),
28.
series: [{
29.
type:
'column'
,
30.
field: metric.MonthValue,
31.
color:
'#ff0000'
,
32.
negativeColor:
'#0099ff'
,
33.
metricType: metric.MetricType
// Hack? or Extension
34.
}],
35.
tooltip: {
36.
format:
function
() {
37.
switch
(metric.MetricType) {
38.
case
0:
// Graduacion
39.
return
"{0:N2}"
;
40.
break
;
41.
case
1:
// Cantidad
42.
return
"{0:N0}"
;
43.
break
;
44.
case
2:
// Moneda
45.
return
"{0:C2}"
;
46.
break
;
47.
case
3:
// Indice
48.
return
"{0:N2}"
;
49.
break
;
50.
case
4:
// Porcentaje
51.
return
"{0:P2}"
;
52.
break
;
53.
case
5:
//Clasificacion
54.
return
"{0}"
;
55.
break
;
56.
}
57.
},
58.
visible:
true
,
59.
shared:
false
60.
}
61.
});
62.
}
<
div
data-role
=
"sparkline"
data-series
=
"[{ 'name': 'Orders', 'type': 'column', 'field': 'Combined.OrderCount' }]"
data-tooltip
=
"{ template: $('#rangeTooltipTemplate').html() }"
data-bind
=
"source: dataSource"
>
</
div
>
@using (Html.BeginScripts("Daily.Range.Order.Count"))
{
<
script
type
=
"text/html"
id
=
"rangeTooltipTemplate"
>
<
div
>#: kendo.toString(dataItem.Date, 'd')# (#: kendo.toString(dataItem.Date, 'ddd') #)</
div
>
<
div
>Count: #: value #</
div
>
</
script
>
}
<
div
data-role
=
"sparkline"
data-theme
=
"bootstrap"
data-series
=
"[{ 'name': 'Out the door', 'type': 'line', 'field': 'Performance.AvgOutTheDoor' }]"
data-tooltip
=
"{ template: $('#PerformanceToolTipOutTheDoor').html() }"
data-bind
=
"source: dataSource, visible: showCharts"
>
</
div
>
@using (Html.BeginScripts("Performance.Range.OutDoorTime", Area.Foot))
{
<
script
id
=
"PerformanceToolTipOutTheDoor"
type
=
"text/template"
>
<
div
>#: kendo.toString(dataItem.Date, 'd')# (#: kendo.toString(dataItem.Date, 'ddd') #)</
div
>
<
div
>Out the door: #: value #</
div
>
</
script
>
}