{"id":682,"date":"2012-10-27T22:50:27","date_gmt":"2012-10-27T22:50:27","guid":{"rendered":"http:\/\/garysieling.com\/blog\/?p=682"},"modified":"2012-10-27T22:50:27","modified_gmt":"2012-10-27T22:50:27","slug":"extjs-3-4-scatter-chart-example","status":"publish","type":"post","link":"https:\/\/www.garysieling.com\/blog\/extjs-3-4-scatter-chart-example\/","title":{"rendered":"ExtJS 3.4 Scatter Chart Example"},"content":{"rendered":"<p><strong>Problem<\/strong><\/p>\n<p>You want to display a scatter chart in ExtJS 3.4. <\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/172.104.26.128\/wp-content\/uploads\/2012\/10\/scatter-3.4.png\" alt=\"\" title=\"scatter-3.4\" width=\"431\" height=\"221\" class=\"alignnone size-full wp-image-683\" srcset=\"https:\/\/www.garysieling.com\/blog\/wp-content\/uploads\/2012\/10\/scatter-3.4.png 431w, https:\/\/www.garysieling.com\/blog\/wp-content\/uploads\/2012\/10\/scatter-3.4-300x154.png 300w\" sizes=\"(max-width: 431px) 100vw, 431px\" \/><\/p>\n<p><strong>Solution<\/strong><\/p>\n<p>Use the Ext.chart.Chart class, and make the lines invisible. <\/p>\n<p><strong>Discussion<\/strong><\/p>\n<p>This example works by rendering an Ext line chart and setting the &#8220;alpha&#8221; (visibility) property of the lines to 0 (transparent). If you wanted to add trend lines, you&#8217;d need to add visible lines. <\/p>\n<p>ExtJS by default loads the charting .swf file from Yahoo&#8217;s CDN, as it uses the charting component from YUI as a base. This was recently updated and no longer works with Ext 3.4- charts do not render at all. Make sure to use the SWF file from the Ext distribution.<\/p>\n<p>This chart resembles one of the ExtJS examples, but their help is fairly poor when it comes to styling. The Yahoo <a href=\"\nhttp:\/\/developer.yahoo.com\/yui\/charts\/#basicstyles\">YUI documentation<\/a> is far more complete.<\/p>\n<p>ExtJS 4 has a scatter chart xtype, which probably works better than this technique.<\/p>\n<pre lang=\"javascript\">\nExt.onReady(function() {\n   Ext.chart.Chart.CHART_URL = 'ext-3.4.0\/resources\/charts.swf';\n   var store = new Ext.data.JsonStore({\n    fields: ['year', 'comedy', 'action', 'drama', 'thriller'],\n    data: [\n        {year: 2005, comedy: 34000000, action: 23890000, drama: 18450000, thriller: 20060000},\n        {year: 2006, comedy: 56703000, action: 38900000, drama: 12650000, thriller: 21000000},\n        {year: 2007, comedy: 42100000, action: 50410000, drama: 25780000, thriller: 23040000},\n        {year: 2008, comedy: 38910000, action: 56070000, drama: 24810000, thriller: 26940000}\n        ]\n  });\n  \n  new Ext.Panel({\n    width: 390,\n    height: 200,\n    renderTo: 'container',\n    title: 'Scatter Plot - Takings by Genre',\n    items: {\n      xtype: 'linechart',\n      store: store,\n      xField: 'year',\n      xAxis: new Ext.chart.NumericAxis({\n        minimum: 2004,\n        maximum: 2009,\n        majorUnit: 1\n\n      }),\n      yAxis: new Ext.chart.NumericAxis({\n        labelRenderer: Ext.util.Format.usMoney\n      }),\n      series: [{\n        yField: 'comedy',\n        displayName: 'Comedy',\n        style: {\n          lineAlpha: 0.0,\n        }\n        \n      },{\n        yField: 'action',\n        displayName: 'Action',\n        style: {\n          lineAlpha: 0.0,\n        }\n      },{\n        yField: 'drama',\n        displayName: 'Drama',\n        style: {\n          lineAlpha: 0.0,\n        }\n      },{\n        yField: 'thriller',\n        displayName: 'Thriller',\n        style: {\n          lineAlpha: 0.0,\n        }\n      }]\n    }\n  });\n});\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Problem You want to display a scatter chart in ExtJS 3.4. Solution Use the Ext.chart.Chart class, and make the lines invisible. Discussion This example works by rendering an Ext line chart and setting the &#8220;alpha&#8221; (visibility) property of the lines to 0 (transparent). If you wanted to add trend lines, you&#8217;d need to add visible &hellip; <\/p>\n<p class=\"link-more\"><a href=\"https:\/\/www.garysieling.com\/blog\/extjs-3-4-scatter-chart-example\/\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;ExtJS 3.4 Scatter Chart Example&#8221;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"om_disable_all_campaigns":false,"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"footnotes":""},"categories":[4],"tags":[154,155,213,214,217,224,240,276,277,302,303,304,316,317,318,319,575],"aioseo_notices":[],"amp_enabled":true,"_links":{"self":[{"href":"https:\/\/www.garysieling.com\/blog\/wp-json\/wp\/v2\/posts\/682"}],"collection":[{"href":"https:\/\/www.garysieling.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.garysieling.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.garysieling.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.garysieling.com\/blog\/wp-json\/wp\/v2\/comments?post=682"}],"version-history":[{"count":0,"href":"https:\/\/www.garysieling.com\/blog\/wp-json\/wp\/v2\/posts\/682\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.garysieling.com\/blog\/wp-json\/wp\/v2\/media?parent=682"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.garysieling.com\/blog\/wp-json\/wp\/v2\/categories?post=682"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.garysieling.com\/blog\/wp-json\/wp\/v2\/tags?post=682"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}