After ajax reads data, it uses jqchart to display charts. ajaxjqchart

Source: Internet
Author: User

After ajax reads data, it uses jqchart to display charts. ajaxjqchart

This document describes how to use jqchart to display charts after ajax reads data. Share it with you for your reference. The specific analysis is as follows:

Recently, chart effects need to be displayed in the project. The originally collected chart plug-ins are useful.

However, there are many differences with jqchart.

Effect:

I wrote jqchart again.

The first solution is not to display the X and Y axes:

// Convert each DIV into // cancel the title display/* this. titleBox // Title = this. mkBoxElement ('T', this. op. titleLeft, this. op. titleTop ). appendTo (this. jQcanvasBox ). css ('width', this. op. width-this.op.titleLeft) // fix for safari3 2007.12.4. get (0); * // cancel the Y axis Number Display/* this. scaleYBox // Y your quota has been reached before = this. mkBoxElement ('y', this. op. scaleYLeft, this. op. scaleYTop ). appendTo (this. jQcanvasBox ). get (0); * // cancel the X axis category display/* this. scaleXBox // X contains invalid variable = this. mkBoxElement ('x', this. op. scaleXLeft, this. op. scaleXTop ). appendTo (this. jQcanvasBox ). get (0 );*/

Secondly, for the inflection point text, the original display is the corresponding data value, now you need to display the corresponding X axis Name:

If (x <= op. width) {var dx = x-op.paddingL, dy = y-op.paddingT; var dxx = I <= 0? (Dx + op. labelDataOffsetX-5 + 'px ') :( dx + op. labelDataOffsetX-20 + 'px'); // coordinate the X axis offset of the coordinate point var dyy = I % 2? (Dy + op. labelDataOffsetY-25 + 'px ') :( dy + op. labelDataOffsetY-5 + 'px '); // coordinate the y-axis offset of it. wrtText (// dx + op. labelDataOffsetX-20 + 'px ', dxx, // dy + op. labelDataOffsetY-10 + 'px ', dyy, // op. rows [I], // pre: coordinate data value op.txt pointers [I], // cychai: coordinate text op, "# jQchart-data-D-" + op. id ).css ('color', (op. data. length = 1 )? '#333': strokeStyle). css ({"width": "100px", "font-size": "12px"}); // cychai: style Control

The default data is displayed. The next step is collaboration with development.

I want to use ajax to obtain data asynchronously and display it on the foreground.

Here, I use chartdata.html on an Example page, that is, the required data page.

[{LabelX: ["design", "portability", "ease of use", "battery standby", "Camera function", "zoom"], data: [5, 7, 2, 3, 9, 4]}]

At the front-end, I request this page through ajax to process the returned json data and pass it to chartSetting:

$ (Function () {$. ajax ({url: "chartdata.html", type: "GET", success: function (cdata) {showDDChart (cdata) ;}}); function showDDChart (cdata) {var dd_chart = eval (cdata) [0]; var chartSetting = {config: {title: "", titleLeft: 70, labelX: dd_chart.labelX, // labelX: ["design", "portability", "usability", "battery standby", "Camera function", "zoom"], scaleY: {min: 0, max: 10, gap: 2}, width: 300 + 25, height: 125 + 50, paddingL: 10, paddingT: 10}, // data, 4, 9] data: dd_chart.data}; $ ('# canvasmyid '). jQchart (chartSetting );}});

Complete html page:

<Head> <! -- [If IE]> <mce: script src = "excanvas-compressed.js" mce_src = "excanvas-compressed.js" type = "text/javascript"> </mce: script> <! [Endif] --> <mce: script src = "http://jsgt.org/lib/jquery/plugin/jqchart/sample/v003/lib/jquery-1.2.3.min.js" mce_src = "http://jsgt.org/lib/jquery/plugin/jqchart/sample/v003/lib/jquery-1.2.3.min.js" type = "text/javascript"> </mce: script> <mce: script src = "jquery. jqchart. js "mce_src =" jquery. jqchart. js "type =" text/javascript "charset =" UTF-8 "> </mce: script> 

OK, all done!

I hope this article will help you with jQuery programming.

Related Article

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.