Ext.ux.Sparkline + Grid Plugin
Hi,
Here's my quick "port" of jquery.sparkline.js to ExtJS + Grids plugin:
http://blog.dgaspar.com/sparkline/sparklinegrid.png
Download: http://github.com/dgaspar/Ext.ux.Sparkline
Live demo: http://blog.dgaspar.com/sparkline/
Examples:
Code:
// Example of a simple sparkline (extends BoxComponent)
// default type is 'line'
new Ext.ux.Sparkline({renderTo:Ext.getBody(),values:[1,2,3,234,345,56,563,34,134,45,456,542]});
// A Grid with sparkline plugin
new Ext.grid.GridPanel({
renderTo:Ext.getBody(),
autoHeight:true,
width:250,
title:'Sparklines',
view : new Ext.grid.GridView({forceFit : true}),
columns: [{
header: 'Name',
dataIndex: 'name'
},{
header: 'Stats',
xtype:'sparklinecolumn',
dataIndex: 'stats',
sparkline:{ type:'bar', barColor:"green" } // default sparkline config for the column
}],
plugins:[new Ext.ux.Sparkline.GridPlugin()],
store:new Ext.data.SimpleStore({
fields:['name', 'stats'],
data: [
['bar (default cfg)', {values:[10,-2,30,10,100,40,6,78,23]}],
['line', {
// the record can override the default cell config:
values:[10,-2,30,10,100,40,6,78,23],
type:'line',
maxSpotColor:'red'
}],
['box', {values:[1,2,3,10,1,4,6,78,23],type:'box'}],
['tristate', {values:[100,50,-13,0,1,4,6,0,-345,345,34,-43,56,7,23],type:'tristate'}],
['discrete', {values:[100,-50,13,345,345,345,34,23,12,56,7,23],type:'discrete'}],
['pie', {values:[10,50,40],type:'pie'}],
['bullet', {values:[10,12,12,9,7],type:'bullet'}]
]
})
});
Known issues:- composite functionality (superposed graphs) is broken
- sparkline_display_visible is broken
- I "guessed" how plugins, columnmodels and boxcomponents should work when I was extending them.. lol
using data from a JSON store
Hello,
I downloaded this plugin and it is exactly what I was looking for. But I am having a problem using the data in the store to have the graph draw. If I force the data it works fine so I know it is something with reading the data from the store.
The data in the store is loaded from a JSON. I have tried different formats for the data. Here are snippets what I have tried:
Code:
"PowerHistory":"{values:[1,10,14,13,17,52,39,43,40,35,30,29,28,27,26]}"
"PowerHistory":"values:[1,10,14,13,17,52,39,43,40,35,30,29,28,27,26]"
"PowerHistory":"[1,10,14,13,17,52,39,43,40,35,30,29,28,27,26]"
"PowerHistory":"1,10,14,13,17,52,39,43,40,35,30,29,28,27,26"
Here is how I have the column configured:
Code:
{header: "Performance", width: 120, sortable: true, dataIndex: 'PowerHistory', xtype: 'sparklinecolumn', sparkline:{type:'line', barColor:"green" } }
I am guessing it is how I am sending the data because if I put values:[1,2,3,4,5] in the sparkline: config I get the graph.
Thanks!
Mike