[ExtJs] line chart

Source: Internet
Author: User

[ExtJs] line chart

ExtJs launched four chart functions after ExtJs4. Although the chart functions can be implemented through other JQuery plug-ins, for example, [jQuery] is compatible with the IE6 chart plug-in Highcharts (click to open the link), but this ExtJs chart plug-in is also very good, at least some common charts are also useless.

 

I. Basic Objectives

Draw the following discount chart:

 

Ii. Production Process

First, define a data entity for the project where ExtJs is used to draw charts. Similarly, define a data entity for the project that interacts with [ExtJs] and the query of the grid with a paging table component in the background database (click to open the link.

 

 Ext.define('graphData',{extend:'Ext.data.Model',fields:[{name:'graphName',type:'string'},{name:'graphData',type:'int'}]});

 

Then, declare the data in the data entity:

 

Var graphDataStore = Ext. create ('ext. data. store', {model: 'graphdata', data: [{graphName: January, graphData: 700}, {graphName: February, graphData: 800}, {graphName: March, graphData: 600 },{ graphName: April, graphData: 500}]});
If the data is provided by the backend page, write as follows:

 

Var graphDataStore = Ext. create ('ext. data. store', {model: 'graphdata', proxy: {type: 'ajax ', url: 'showdata. php ', // page reader: {type: 'json', root: 'data', }}, autoLoad: true} that provides Json strings });

The following string is printed on the showData. php page:

 

{'Success': true, 'data': [{graphName: January, graphData: 700}, {graphName: February, graphData: 800}, {graphName: March, graphData: 600 },{ graphName: April, graphData: 500}]}
Draw a line chart:

 

 

Var chart = new Ext. chart. Chart ({// the following four items must be specified. Otherwise, it cannot be displayed. Width: 480, height: 320, store: graphDataStore, renderTo: Ext. getBody (), axes: [{// declare the type: 'numeric ', position: 'left', fields: 'graphdata'}, and {type: 'category ', position: 'bottom', fields: 'graphname'}], series: [{// declare what type: 'line' is used to fill data on the x and Y axes, respectively ', axis: 'left', xField: 'graphname', yField: 'graphdata'}]});
 
  <Script type = text/javascript src = .. /js/ext-all.js> </script> <script type = text/javascript src = .. /js/bootstrap. js> </script> <script type = text/javascript src = .. /js/ext-lang-zh_CN.js> </script>  


 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.