In this article, we will discuss How to make sharp lines to smooth curved lines using Chart JS. If you are new at charts js and you are looking for converting this graph to a smooth line chart then you have come to the right place.
If you take the default example from the chart js then you will get the sharp lines but our requirement is to make it smooth curve lines using chart js.
we can easily achieve this task using the option lineTension that needs to be defined on the line chart dataset. set a value below 1.
lineTension
: Bezier curve tension of the line. Set to 0 to draw straight lines. Source: Chart Js Documentation
Make Sharp Lines to Smooth Curved Lines
<!DOCTYPE html>
<html>
<head>
<title>Set Different Color For Each Bar based on value Using chart.js</title>
<script src="https://cdn.jsdelivr.net/npm/chart.js@3.7.1/dist/chart.min.js"></script>
</head>
<body>
<div style="margin-left:5%;margin-right:5%">
<canvas id="linechart" style="width:80%"></canvas>
</div>
<script>
var LineChartData = {
labels: [
"Jan",
"Feb",
"Mar",
"Apr",
"May",
"June",
"July",
"Aug",
"Sep",
"Oct",
"Nov",
"Dec"
],
datasets: [
{
label: "sales",
borderWidth: 2,
backgroundColor: "blue",
borderColor:"red",
lineTension: 1,
data: [42, 56, 9, 52, 66, 87, 51, 42, 32, 88,150,125]
}
]
};
const config = {
type: 'line',
data: LineChartData,
options: {
scales: {
y: {
beginAtZero: true
}
}
},
title: {
display: true,
text: "Smooth curve line chart"
}
};
window.onload = function () {
new Chart("linechart", config);
};
</script>
</body>
</html>
sxds
The post [Chart JS]- How to Make Sharp Lines to Smooth Curved Lines? appeared first on Software Development | Programming Tutorials.
Read More Articles
- [Simple Way]-Cascading DropDownList in Asp.Net Mvc Using Jquery Ajax
- jQuery Ajax GET Example with Parameters
- How to Pass Parameters in AJAX POST?| JQuery Ajax Post Json Example
- [Simple Way]-How to get data from database using JQuery Ajax in asp net MVC
- How to add, edit and delete rows of an HTML table with Jquery?
- Registration form with image upload in MVC using jquery Ajax
- How to make an Inline editable table in MVC using jquery?
- Insert Update Delete Using Jquery Ajax and Modal Popup in Mvc
- [Solved]-How to Upload pdf file using jquery MVC?
- Dynamically creating graphs with jQuery
- Transform Scale on scroll
- onclick function executed even when i clicked some other event
- How can I force content_tag_for to use dashes instead of underscores when making the element's id?
- Trying to create an input that only allow user enter word once in this jquery?
- Is there any way to use subtitles with mp3s?
- How to uncheck checkbox before change() event is triggered
- How to select an li with jQuery using multiple data-attributes and multiple logical conditions
- adding and retrieving arrays from localStorage
- Why does JQuery Clip not work?
- -ms-filter for gradient in IE8 via jquery
- Namespace issue in javascript
- Find a character in the string
- Clickable second td of the table not working
- How do I parse a remote page for images using the name attribute using jquery?
- How to change an image when clicked using JavaScript?
- symfony2 : persist entity with ajax
- Jquery .val() on a Object
- only first form is checked by jQuery
- Image hover gallery with link
- How can I remove an element from a list returned by a jQuery selector?
- AngularJS, directive element is null
- How to get to the 5th HTML Table in the DOM Using jQuery?
- Javascript get city name from google autocomplete or from lat and lng
- JavaScript to add class to (li) Parent
- Why Object [ID] has no method 'Animate'?
- jquery storing arbitrary element data to be used in callbacks
- How to exit a function embedded in an $.each() block?
- JQuery: what's the difference between these two $.get() methods?
- How do you update a KnockOutJs ViewModel from a jquery ajax call?
- Custom button on CKEditor's File Browser
- Jquery works in Safari but not in Firefox 11
- How to get name and get value from select box?
- jQuery conditional problem
- jQuery - fadeOut div on click anywhere but specified selector?
- Dropdown menu using Twitter Bootstrap (JS and Jquery) doesn't drop down--what is wrong?
- KendoAutoComplete - Selecteditem Id
- JQuery remove class from list of items one by one with a delay
- Is it possible to get the url from a link clicked in an iframe?
- href links in my project are not clickable
- CSS triangle custom border color not working
- To get the value from particular hidden field
- Summernote: Enable Air-mode along with the default toolbar
- How can I use an array of values as a jQuery selector argument?
- How can I stop jquery animation in my slideshow
- Odd Behaviour From jQuery Animate
- Reduce animations code repetition in jQuery
- How to make array from different value in jQuery
- Setting a minimum height and width on JCrop
- Legend in horizontal multi bar chart
- failing to get jsonp response using jquery ajax
- JSON Web Service to check for common misspellings in popular names, e.g. "Aberaham Lincoln"?
- How can we use find() API to find a string in the page URL.?
- Total Price update from multiple selections using data-* attribute
- Why isn't my text inline?
- Trigger jQuery's hover() over anchor to show drop-downs within containing LIs?
- How to cancel an ajax query (from jquery) on the server side?
- JointJS Basic understanding
- jQuery / JS wait until image width adjusted
- Getting the value of a prepopulated field
- jquery/html interpolation
- Inject a iframe on a HTTPS web Page
- Looping an object with an string array
- jQuery tooltips stop working after AJAX form submission
- how to call a pagemethod in a user control using jquery?
- Calling a jQuery function using a variable name
- How to add a html element after last child of list item
- How to use a for loop variable in php that is declared in javascript language
- How to search for objects properties inside arrays?
- Checking if input value isn't empty working as wanted
- html input tag always reads null in Javascript
- How can I avoid reseting inputs in a form in Rails 4
- jquery undelegate click event after event has completed
- jquery not working while implemented in html header of Wordpress
- selecting all checkboxes in jquery
- How to get all the descendants of an elements?
- PHP: Respond to ajax request only
- How can I access the HTML stored in a jquery object?
- jquery each loop check if at least one field has been filled
- How to do, Multiple Overlayed videos using flowplayer (jQuery)
- how to update a row through a row button click
- C# ASP.NET How to modify CSS class via code-behind
- AJAX navigation in Wordpress - Trouble with Permalinks
- How to count the number of alert boxes created in a web page?
- Making jquery ajax post request when post body content is JSON but response is HTML
- How can i implement textbox auto suggest using jquery in my c# asp.net application?
- replace form id with new id?
- Jquery autocomple for multiple fields (created dynamicly)
- How do I submit a form without refreshing the current page?
- How to find the value inside a span using jquery?
- javascript script tags and ajax issue
- run javascript after everytime page is loaded
- undefined return ajax success
- jQuery - why can't I bind events to elements in a loop?
- Can't get tooltip to go away
- Json result only returning 1 row
- Check if element with same name attribute exists jQuery
- How to retain checkbox state in jQuery
- how to fixed a navbar and Carousel image slider in bootstrap
- MVC select model's data from javascript
- How removing dragged element only if it has a certain class?
- jquery selection on a select list
- Jquery datepicker display all days of month for a year
- how to calculate total based on check box checked.?
- Get value from JSON data using jQuery
- how to get the class name of divs?
- existing function is undefined
- Get data from php-foreach-loop to ajax
- Dynamically update/display the content on the HTML
- Jquery watch certain fields for certain values
- Json string aren't being displayed on my jsp page
- Executing codes on website without the website being accessed PHP
- Value of variable with "var" keyword changes after using the same variable in For loop
- How to show two horizontal scroll menu bars
- fadeOut() one table, fadeIn() another
- Button "show password" not working
- How to catch model value in Angular which appended with click?
- Word wrap up to two lines in a table cell
- javascript - redirecting
- how to access returned array object
- Efficent function replaceWith for multiple classes
- alert(data.status) fails when status=false but not when status=true
- How to get client side validation on a date string model property
- JQuery Slider width, variable <li> element widths - how do?
- How can the jQuery code for initialization be simplified?
- How to change id font-size using jQuery .attr()?
- Pass variable to multiSelect value
- Dynamically assign property name to object
- get custom attribute value in jquery
- Looping jQuery function
- Proper ways to handle asynchronous functions
- mass customization web app - performance issue
- canvas to limit area for fabricjs object
- Custom Javascript Light-box
- Upload non-latin name file with jQuery
- Get height value in real time whilst CSS transition is in progress
- IE issue with styling <select/> element
- Targeting previous div in javascript or css
- jquery-ajax pass html element value from one page to another
- change url using jquery for specific css classes
- Communication between background.js and content-script? Response is UNDEFINED
- this code wont run on jquery-3.1.0.js
- enable\disable elements by radiobuttons
- Fancybox Pop Up Warning for IE 7
- javascript setTimout not stopping for specifc time
- jQuery Animation error = attempt to run compile-and-go script on a cleared scope
- Manipulate Json String Jquery
- This selector doesn't work inside time out
- Altering meta viewport tag
- jquery get elements attibute value and create variable from it
- Condensing Javascript/jQuery Code