Chart.js plug-in generates a line chart when data is generally large when the y-axis data is not starting from 0 solution [bubuko.com]

Source: Internet
Author: User

Chart.js plug-in generates a line chart when data is generally large when y-axis data is not starting from 0 solution, original: http://bubuko.com/infodetail-328671.html

By default, such as

The y-axis is not starting from 0, so the amplitude of the discounted graph will be very large, not the normal amplitude, the solution is as follows,

Example code:


Window.onload = function () {            var ctx = document.getElementById ("Canvas"). GetContext ("2d");            Window.myline = new Chart (CTX). Line (Linechartdata,  {                scaleoverride:true,   //whether to rewrite y-axis gridlines scalesteps:15 with hard coding                ,        number                of//y axis ticks scalestepwidth:300,   //y axis each scale width                scalestartvalue:0,    //y axis start value                pointdot:true,        //Whether the point is displayed                pointdotradius:5,     //radius of the                pointdotstrokewidth:1,//point of the line width                datasetstrokewidth:3,//Line width                of the data line Animation:true,//       whether there are animation effects                animationsteps:60    //animation Steps                });        

Core code:



Scaleoverride:true,//   whether to rewrite the y-axis grid line scalesteps:15 with hard coding,        the number of//y axis ticks scalestepwidth:300,   // Y-Axis The width of each scale scalestartvalue:0, the    starting value of the//y axis

This will give you the following effect, the y-axis starting from 0


Http://bubuko.com/analysis-201408.html

Chart.js plug-in generates a line chart when data is generally large when the y-axis data is not starting from 0 solution [bubuko.com]

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.