extjs-gpl
Version:
GPL licensed version of Sencha Ext JS
191 lines (187 loc) • 5.02 kB
JavaScript
/**
* Marked lines are multi-series lines displaying trends across multiple categories.
* Markers are placed at each point to clearly depict their position on the chart.
*/
Ext.define('KitchenSink.view.charts.line.Marked', {
extend: 'Ext.panel.Panel',
xtype: 'line-marked',
controller: 'line-marked',
// <example>
// Content between example tags is omitted from code preview.
bodyStyle: 'background: transparent !important',
layout: {
type: 'vbox',
pack: 'center'
},
otherContent: [{
type: 'Controller',
path: 'classic/samples/view/charts/line/MarkedController.js'
}, {
type: 'Store',
path: 'classic/samples/store/Browsers.js'
}],
// </example>
width: 650,
tbar: [
'->',
{
text: 'Toggle markers',
handler: 'onToggleMarkers'
},
{
text: 'Preview',
handler: 'onPreview'
}
],
items: [{
xtype: 'cartesian',
reference: 'chart',
width: '100%',
height: 500,
legend: {
type: 'sprite',
docked: 'right'
},
store: {
type: 'browsers'
},
insetPadding: 40,
sprites: [{
type: 'text',
text: 'Line Charts - Marked Lines',
fontSize: 22,
width: 100,
height: 30,
x: 40, // the sprite x position
y: 20 // the sprite y position
}, {
type: 'text',
text: 'Data: Browser Stats 2012',
fontSize: 10,
x: 12,
y: 470
}, {
type: 'text',
text: 'Source: http://www.w3schools.com/',
fontSize: 10,
x: 12,
y: 485
}],
axes: [{
type: 'numeric',
fields: ['data1', 'data2', 'data3', 'data4' ],
position: 'left',
grid: true,
minimum: 0,
renderer: 'onAxisLabelRender'
}, {
type: 'category',
fields: 'month',
position: 'bottom',
grid: true,
label: {
rotate: {
degrees: -45
}
}
}],
series: [{
type: 'line',
title: 'IE',
xField: 'month',
yField: 'data1',
marker: {
type: 'square',
fx: {
duration: 200,
easing: 'backOut'
}
},
highlightCfg: {
scaling: 2
},
tooltip: {
trackMouse: true,
renderer: 'onSeriesTooltipRender'
}
}, {
type: 'line',
title: 'Firefox',
xField: 'month',
yField: 'data2',
marker: {
type: 'triangle',
fx: {
duration: 200,
easing: 'backOut'
}
},
highlightCfg: {
scaling: 2
},
tooltip: {
trackMouse: true,
renderer: 'onSeriesTooltipRender'
}
}, {
type: 'line',
title: 'Chrome',
xField: 'month',
yField: 'data3',
marker: {
type: 'arrow',
fx: {
duration: 200,
easing: 'backOut'
}
},
highlightCfg: {
scaling: 2
},
tooltip: {
trackMouse: true,
renderer: 'onSeriesTooltipRender'
}
}, {
type: 'line',
title: 'Safari',
xField: 'month',
yField: 'data4',
marker: {
type: 'cross',
fx: {
duration: 200,
easing: 'backOut'
}
},
highlightCfg: {
scaling: 2
},
tooltip: {
trackMouse: true,
renderer: 'onSeriesTooltipRender'
}
}]
//<example>
}, {
style: 'margin-top: 10px;',
xtype: 'gridpanel',
columns : {
defaults: {
sortable: false,
menuDisabled: true,
renderer: 'onColumnRender'
},
items: [
{ text: 'Month', dataIndex: 'month', renderer: Ext.identityFn },
{ text: 'IE', dataIndex: 'data1' },
{ text: 'Firefox', dataIndex: 'data2' },
{ text: 'Chrome', dataIndex: 'data3' },
{ text: 'Safari', dataIndex: 'data4' }
]
},
store: {type: 'browsers'},
width: '100%'
//</example>
}]
});