score:4
Unfortunately, there is no such capability in chart.js today. However, that doesn't mean you can't still get the functionality that you want. There are a couple of options that come to mind.
1) Implement your own jitter
function and use it to pre-process your data before passing to chart.js. Here is an example.
var jitter = function(data) {
return data.map(function(e) {
var xJitter = Math.random() * (-1 - 1) + 1;
var yJitter = Math.random() * (-1 - 1) + 1;
return {
x: e.x + xJitter,
y: e.y + yJitter,
}
});
};
Here is a codepen example showing a side by side example of charts with original and jittered data.
2) Use the jitter
function above and add it as a chart.js plugin such that you can enable/disable it automatically in any given chart. Here is an example (note that we are using the jitter
function above.
Chart.plugins.register({
afterInit: function(chartInstance) {
if (chartInstance.config.options.jitter) {
var helpers = Chart.helpers;
var ctx = chartInstance.chart.ctx;
chartInstance.data.datasets.forEach(function (dataset) {
dataset.data = jitter(dataset.data);
});
}
}
});
Then just add this into your charts options config.
options: {
jitter: true,
}
Here is a codepen example showing a side by side example of charts with original and jittered data using the plugin.
Obviously, you would want to implement a much more robust jitter
function that accepts some sort of jitter options so that it can be intelligently applied to any type of dataset. I'll leave that for you to implement if you decide to take this approach.
Source: stackoverflow.com
Related Query
- Hide points in ChartJS LineGraph
- Skip decimal points on y-axis in chartJS
- Adding Image inside Linechart points in ChartJs
- ChartJS : How to leave just points without lines
- Chartjs 2 scaling lots of data points
- Chartjs Line Color Between Two Points
- ChartJS bar not showing up for simple data points
- ChartJs line chart - display permanent icon above some data points with text on hover
- How to make points in chartjs draggable?
- Add Commas to ChartJS Data Points
- ChartJS - handling of overlapping points in line chart
- How to add ChartJS code in Html2Pdf to view image
- chartJS - points overplotting, jittering, noise?
- Points cut at half at the edges of top and bottom, at chartjs
- How to remove some points in chartjs
- Missing Tooltip for some data points using chartjs
- How do I add time sourced from an external source as an X axis to a ChartJS graph?
- How to combine lines with different starting points in chartjs
- Chartjs not working with d3 from csv source
- ChartJS radar scale points
- Chartjs not showing all data points
- How to hide some points inside my line graphic in React ChartJS 2?
- ChartJS show jittering on hover
- How to reduce the number of points shown on line chartjs chart with a large dataset?
- ChartJS - How to change color of some data points in graph
- How to properly feed data to ChartJS with different number of x(labels) and y(data) points
- ChartJS have xAxes labels match data source
- chartjs line graph points with different color
- Updating Chartjs to 2.5 with custom code
- ChartJS hover/tooltips: selecting the correct points in the datasets based on x-value
More Query from same tag
- Create a prop for a chart.js pie chart
- Javascript in wordpress causes SyntaxError
- Is there any way to get Chiselled Effect in chart js?
- Chart.js - Timeline
- Angular-chart copied from example not showing up
- How update reload chart.js
- Chart.js polar chart
- How do I remove cartesian axes from chart js?
- Is there way to get counts of every day of week by created_at in laravel php
- Chartjs linechart with only one point - how to center
- integrate a scroll bar along with chartjs-zoom-plugin
- How can I show texts only if they fit in the arc in Chart.Js 2.8.0?
- Populating a chartJS with data from API through axios (VueJS)
- Shorten number labels in Charts.js
- Chartjs display bug when pushing data to graph
- Using Createjs and Chartjs
- Charts.js DataIndex not updating based on selected datasets
- Chart.js create line graph using dates in the x-axis that reflect real time intervals (not evenly distributed)
- Emphasize a point in Chart.js
- About the charts in react-native
- Integrate Blazor with Chart.js: how to pass an object
- How to pass a dictionary to ChartJS?
- Allowing Chart.js to work with jQuery Tabs
- Chart.js bars have non uniform widths
- How to remove percentage calculation on top of bar in ng2-chart bar chart
- How to hide the legend display for a specific chart?
- Update chart.js after form submission and page reload
- Angular-chartjs expression/value inside canvas class
- How to show Charts.js lables
- PrimeNg chart label rotation with Angular2