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
- Difference between a form post and jquery post
- How to upload InMemoryUploadedFile to my S3 Bucket?
- jQuery equivalent of JavaScript's addEventListener method
- Insert hyphen(-) automatically while typing an SSN in a Textbox using jQuery
- JavaScript JQuery Ajax Issue: POST Works fine in Firefox, IE, Safari but not Chrome
- TextArea element - default size to fit content
- How to display datatable button separate from button group?
- JQuery `live()` and `submit()` problem
- Run ScrollTop with offset of element by ID
- JQuery Tag It - Edit tags inline
- How to access the value of a data attribute using jQuery
- Javascript get key of multidimensional array
- How to remove inherited styles using jQuery?
- Jquery .each() including a delay looking for clean code
- Custom events in jQuery?
- Fancybox 3: Disable zoom when image is clicked
- jquery remove all elements except for first one
- How to load the web page content based on user scrolling
- How to programmatically check a Bootstrap button group (radio) button
- How to recreate the GitHub Network Graph
- jQuery UI draggable and adding class on drag event
- A potentially dangerous Request.QueryString value was detected from the client when sending html markup from jquery post call to asp.net page
- Is it preferred to use css instead of jquery when both get the same job done?
- is there something like isset of php in javascript/jQuery?
- How to prevent an <img> tag from loading its image?
- Delete an element inside a JSON array by value with jQuery
- Multiple calculations, display on same page
- How to store active class of a div when page reloads using local storage
- Why am I seeing "Error - Only secure origins are allowed" for my service worker?
- jQuery - "fadeIn is not a function"
- Append/Prepend space on outer tag
- How to escape # symbol in url?
- SweetAlert2 execute function after timer
- JQuery mobile + Phonegap : Ajax calls not working on Android Emulator
- jQuery Remove string from string
- Closure compiler app using jquery
- Convert date format in jquery
- jQuery .ajax() does not work in Safari when it takes seconds to get returned data
- How to submit form and update element on the page without refresh, in Rails 4
- Focus and blur jQuery events not bubbling
- Remove/destroy Nicescroll bar from element (integration with JQuery MultiSelect)
- jQuery: how do I add a div to the end of my HTML file?
- Send data to MVC controller using JSON
- jQuery not handling JSON response from AJAX POST
- Refresh Partial View Div in MVC 5
- jQuery Deferred/Promises dynamic array not executing callbacks in correct order
- How avoid sibling element from shaking when animate with jquery
- jQuery Toggle with Cookie
- Extend ES6 plugin to jQuery prototype
- Uncaught ReferenceError: $ is not defined - Laravel 5.5 + Laravel Mix
- Knockout.js seems to be clobbering my jQuery event handlers, how rude
- How to make a jquery datePicker button image unclickable
- how to prevent using space while typing?
- Jquery UI selectmenu inside modal dialog
- jQuery - simple input validation - "empty" and "not empty"
- Twitter OAuth authentication in javascript
- How to dynamically scroll focus a particular highlighted div
- How to Maintain Parent Width for a Fixed Floating Div that Requires Position:Fixed
- How to reload data in Google Charts Calendar while keeping selected cell?
- jquery ui dialogs and loading external content
- Dynamically adding options and optgroups in Select2
- jQuery add css value incrementally
- Raphaeljs: How to get the elements reference back using event.target?
- Jquery ajax and controller method
- jQuery get index position of an element by class from an array
- Open image to print in new window using jQuery
- Detect if an element is selected in listbox or not through jquery
- Turning jQuery into Angular, fixed sidebar not working (?)
- Ignore click on div
- Lazy load for table
- Is there a way to shim the "dd-MON-yyyy" date format for IE
- How to find all input elements with a given prefix within a div?
- Change color of multiple items based on the data attribute
- Javascript Error: Uncaught ReferenceError: edit is not defined
- jQuery wait for replaceWith to finish before executing
- Why should $.click() be enclosed within $(document).ready()?
- jQuery: add content to end of div
- How to highlight jQuery Autocomplete results that match the text already typed?
- Javascript language and the $ in jquery
- Get id of previous tag
- jQuery File Upload preview image
- jQuery $().css("content") returning the string "normal" in IE9
- Sending multiple file input fields programmatically in one form
- Prettier way to write this script (Hide span on click, show input)
- Binding jQuery element clicks with Google Map Markers
- Retain Twitter Bootstrap Collapse state on Page refresh/Navigation
- Call a function before synchronous call
- How to use Angular JS with Leaflet.js
- ReferenceError: define is not defined while embedding fuelux in datagrid.js
- Arrange arrays elements with javascript and jquery
- jquery loading image while elements loads
- "setTimeout" VS "debounce" plugin - to defer code execution on events
- HTML after iframe neglected
- jQuery: Fullscreen "background" image that moves according to mouse position
- how to read FormData object in php
- Jquery slide left to right makes div jump up on slide
- Comparing variable to empty jquery object in if condition
- JavaScript/JQuery: $(window).resize how to fire AFTER the resize is completed?
- How to collapse/expand list using bootstrap/jquery
- Is there a way to move data labels to the side of a stacked column in HighCharts?
- How do I make my button reveal one item at a time?
- Devbridge JQuery Autocomplete not working with serviceUrl
- Issue in select option in Jquery mobile
- How to load google fonts?
- Merge direct HTML siblings into one in jQuery
- jQuery ui droppable not firing
- Bootstrap <option> rgba color
- Get Data From Datatables.net after sorting
- jQuery Mobile + Backbone tap event fires twice
- Highlight a select / dropdown with a class when its open or is has a option other than the initial default selected
- Jquery UI dialog in place of javascript confirm
- jQuery to check if ID value has a number
- Scripts are being load more than once in Wordpress
- jQuery selector returns prevObject instead of normal element
- adding large amount of elements to DOM
- Show cookie-enabled Jquery notification message on page load
- jQuery text() change on toggle()?
- Hide Textbox Field and Label associated with it
- if div has class change content - three cases
- What does the dot after dollar sign mean in jQuery when declaring variables?
- Vanilla JavaScript instead of jQuery - ready, on, click and end selector
- What exactly is the sAjaxSource parameter in datatables?
- how to stick the footer to the bottom of the page while moving it upward in a parallax-like effect?
- blinking and flicker when updating div contents from ajax
- jQuery wrap text in a span before and after br within a paragraph
- jQuery.post() failure callback function?
- try to setTimeout to show and hide the balls
- Is Modernizr really needed if you're not using the feature detection?
- How do I construct query strings for ajax url with jquery or javascript?
- jQuery ajaxTransport ignores data when returning error
- How can I set the default size of a jquery datepicker?
- jQuery UI Tabs back button history
- Issue using nth-child
- How to modify XML with JQuery
- Get ID of clicked on element in function
- How to cut the string in javascript so that it fits exactly two lines & add ... at the end
- jQuery - Find out which element is directly behind another
- .append not adding .item to .list
- jQuery stop setTimeout if user clicks in input field
- getting a custom tag value using jquery
- JavaScript Namespace with jQuery
- How to create a stripe charge with a checkout token sent via AJAX to php
- pure css slider
- Using jQuery to keep scrolling object within visible window
- Full Calendar show events as dots
- Selector for grandchildren, or how to anchor the selector on a known element
- Is it possible to find from what value a .change() was triggered?
- select2 jquery plugin not working after ajax calling for HTML content change
- jQuery - Event/animation timeline
- Bind doesn't work on first KeyPress using jQuery