Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Interactive visual analytics using Sencha Charts by Vitaly Kravchenko

Interactive visual analytics using Sencha Charts by Vitaly Kravchenko

Charts and graphs are core to any enterprise grade analytics application. With Ext JS 5, Sencha Charts (formerly a part of Sencha Touch) provide advanced charting capabilities with interactive features for both desktop and mobile devices. The session walks through all the Do's and Don'ts of using Sencha Charts, how to add interactions, and how to migrate from old Ext JS Charts package to Sencha Charts. You will also learn about the fundamentals of sprites to customize the rendering of various charts elements.

Lee Boonstra

June 03, 2015
Tweet

More Decks by Lee Boonstra

Other Decks in Technology

Transcript

  1. items: {
 xtype: 'cartesian',
 
 series: {
 type: 'bar3d'
 },


    
 axes: [{
 type: 'numeric3d',
 position: 'left'
 }, {
 type: 'category3d',
 position: 'bottom'
 }]
 } 3D Bar
  2. {label: 'year', span: 100}, // Northeast region
 {label: 'CT', span:

    100, y2007: 0.2, ..., y2012: -0.6, state: 'Connecticut'},
 {label: 'DE', span: 100, y2007: 0.0, ..., y2012: -0.3, state: 'Delaware'},
 ...
 
 {label: '', span: 20}, 
 // Southeast region
 {label: 'AL', span: 100, y2007: -0.1, ..., y2012: -1.4, state: 'Alabama'},
 {label: 'DC', span: 100, y2007: -0.2, ..., y2012: -1.1, state: 'District of Columbia’}, ...
  3. items: [
 {
 xtype: 'polar',
 
 store: {
 type: 'unemployment'


    },
 
 series: [{ 
 type: ‘pie', 
 angleField: 'span',
 
 donut: 93
 
 }]
 }
 ]
  4. layout: 'absolute',
 width: 990,
 
 items: [
 {
 xtype: 'polar',


    
 width: '100%',
 height: 1375, 
 insetPadding: '400 0 125 0’, . . . 400 0 0 125
  5. sprites: [
 {
 type: 'rect',
 x: 50,
 y: 40,
 width:

    890,
 height: 100,
 fillStyle: 'rgb(77, 77, 77)'
 },
 {
 type: 'text',
 text: 'Changes in U.S. Unemployment',
 font: 'bold 54px Charter',
 fillStyle: 'white',
 x: 70,
 y: 120
 }
  6. series: {
 type: 'pie',
 . . . 
 label: {


    field: ‘label', 
 display: ‘inside', 
 fillStyle: ‘white', 
 fontSize: 13, fontWeight: ‘bold',
 fontFamily: 'Tahoma'
 }
 }
  7. 29

  8. series: {
 type: 'pie',
 angleField: ‘span', ...,
 
 label: {


    field: ‘label', ...,
 
 renderer: 'onLabelRender2012'
 }, renderer: 'onSliceRender2012'
 
 }
  9. onLabelRender2012: function (text, sprite, config, data, index) {
 if (text

    === 'year') {
 return {
 text: '2012',
 font: 'bold 16px sans-serif'
 };
 }
 }
  10. onSliceRender2012: function (sprite, config, data, index) {
 var record =

    data.store.getAt(index),
 label = record.get('label'),
 unemployment = record.get('y2012'),
 style = {};
 
 if (label === '') {
 style.fillStyle = 'none';
 style.strokeStyle = 'none';
 } else if (label === 'year') {
 style.fillStyle = ‘#444';
 } else {
 style.fillStyle = this.getStateColor(unemployment);
 }
 return style;
 }
  11. 33

  12. series: [{
 type: 'pie',
 angleField: 'span',
 
 donut: 93
 },

    {
 type: 'pie',
 angleField: 'span',
 
 radiusFactor: 93,
 donut: 86
 }, {
 type: 'pie',
 angleField: 'span',
 
 radiusFactor: 86,
 donut: 79,
 }, { . . .
  13. highlight: true highlightCfg: {
 margin: 20
 } highlight: {
 fillStyle:

    'yellow'
 } highlight: {
 fillStyle: ‘yellow', margin: 0
 } highlightCfg: {
 fllStyle: 'yellow'
 }
  14. {
 xtype: 'polar',
 
 interactions: ['itemhighlight'],
 
 series: [
 {


    type: 'pie',
 angleField: 'span',
 
 donut: 57,
 
 subStyle: {
 fillStyle: 'none',
 strokeStyle: 'none'
 },
 
 highlightCfg: {
 fillStyle: 'rgba(0,0,0,0.2)'
 }, . . .
  15. {
 xtype: 'cartesian',
 
 width: 350,
 height: 250,
 
 x:

    300,
 y: 700,
 
 series: {
 type: 'bar',
 
 xField: 'year',
 yField: 'percent',
 
 renderer: 'onBarRender'
 } }
  16. var storeData = [
 {year: '2007', percent: recordData.y2007},
 {year: '2008',

    percent: recordData.y2008},
 {year: '2009', percent: recordData.y2009},
 {year: '2010', percent: recordData.y2010},
 {year: '2011', percent: recordData.y2011},
 {year: '2012', percent: recordData.y2012}
 ]; onItemHighlight: function (chart, item) {
 
 var recordData = item.record.data; this.lookupReference('cartesian').getStore().setData(storeData);
  17. Surface management Ext.draw.Container config: {
 resizeHandler: null } drawContainer.renderFrame(); defaultResizeHandler:

    function (size) {
 this.getItems().each(function (surface) {
 surface.setRect([0, 0, size.width, size.height]);
 });
 }
  18. Draw Surface Ext.draw.Surface Ext.draw.engine.Canvas Ext.draw.engine.Svg Canvas VML SVG Ext.draw.engine.SvgContext Native

    Canvas 2D context Ext.draw.engine.excanvas Ext.Widget Ext.Component CLASSIC MODERN