score:0
if you're looking for exponential decay, do you need to use math.pow()
? what's wrong with something like
left = left*factor
where 0 < factor < 1
?
looking at some documentation for math.pow()
, the two arguments are base and exponent. in your example, left - 30^30
doesn't make much sense because it will result in a vastly negative number and then default to 0.
an expression using math.pow()
that will give the i
th term of an exponential decay sequence is
start_value * math.pow(factor, i)
where again, 0 < factor < 1
. the reduction in the value that you start with is compounded exponentially over each iteration.
score:2
according to the graph, what you want is to start at (0,10) and then divide y
by 2 every time x
is incremented by 1.
try this:
var time_data = [];
var value_data = [];
for (let i=0;i<=10;++i) {
time_data.push(i);
value_data.push(10/math.pow(2,i));
}
this can be mathematically written as a decreasing exponential: 10 * 2^(-x)
or if you prefer 10 * exp(-ln(2) * x)
Source: stackoverflow.com
Related Query
- Exponential decrease
- How to run Chart.js samples using source code
- How to Increase the label font size and decrease the size of my pie using chart.js?
- How to add ChartJS code in Html2Pdf to view image
- How do I add time sourced from an external source as an X axis to a ChartJS graph?
- code works fine on jsfiddle but one function is not working on website
- Chartjs not working with d3 from csv source
- Passing an Array from a Flask view to the javascript code of another view
- How to generate color code dynamically by swapping 2 characters within a string using PHP
- Code doesn't work after updating chart.js versioning
- Using Chart.js onClick function, can you execute code from an undefined or null result?
- How to write better code in es6 for formatting an object with array values
- Problem with script src for Chart.js. The CDN for Chart.js funtions fine, so my code is ok. Somehow I'm not linking the file correctly
- ChartJS have xAxes labels match data source
- Updating Chartjs to 2.5 with custom code
- what is wrong with my code ? java script chart position
- How to print a chart rendered by code
- How to decrease bottom width of triangle using line chart in chartJs?
- Calling data from outside of Chartjs code
- VueJS + Chartjs - Chart only renders after code change
- How to decrease border width in any charts?
- decrease bar spacing chartJS v2
- How do I destroy/update Chart Data in this chart.js code example?
- ChartJS 2.0 differences in code help needed
- getting additional value fields from data source for dx.chartjs doughnut chart
- I am using chart js to draw a chart. I did everything right but i don't know why the x axis and y axis label is not comming in chart. code below
- My Chartjs is not updating after setstate full code attached Reactjs Update
- Chartjs Line chart options display increase and decrease percentage between each datapoint
- how to decrease white space of a card containing pie-chart in mobile view
- Chartjs doc examples are lightning fast but same code is slow when reproducing
More Query from same tag
- Radarwidth beyond label chart.js
- In Chart.js I want to show dotted gridLines like in below image
- Chart.js not show in my function (function used in ajax) jquery
- Style individual points from one dataset in Chart.js
- Char.js Interpolation linear
- How can I append a calculated value to the end of a bar in Chart.JS?
- How to set Solid label in bar chart using Chart JS
- How to check if HTML5 canvas element contains something in given coordinate region using javascript
- Representing multiple subsections within a section of a doughnut chart Chart.js
- Chartjs Custom Legend for Doughnut Chart Having Labelled Lines Sticking Out of Each Section
- how to create bar chart with group and sam color for each group using chart.js?
- ChartJS chart not scaling after adding values
- int Array with empty value
- how to use chart.js with react Hook?
- How can I update my ChartJS in real time (It's works only when I zoom-in and zoom-out)
- Sort one array and keep other two arrays in sync
- How to install Chart.js in Laravel? ("Uncaught ReferenceError: Chart is not defined")
- How to set chart's percentageInnerCutout property with ng2-charts
- Multiple ChartJS scripts are not working at the same time
- Create a heatmap/punchcard Using Chart.js
- How to rotate the Label text in doughnut chart slice vertically in chart.js canvas, Angular 12?
- Ng2-Charts in Angular: Is 'Auto' supported for display property of Axes
- ChartJS : Hook before values are given to doughnut (absolute value in chart and real values in the tooltips)
- How do I scrape data in <canvas> element with python or javascript?
- How do I selecting a date range (like onClick but drag/select)
- Create a line chart using an user input table from a data table in chart.js
- Remove empty spaces created by null values in Chart.js
- In ChartJS is it possible to change the line style between different points?
- System.ArgumentException: Column 'COLUMN_NAME' does not belong to table
- Chart.js Radial axes: is it possible to use multiple axes on radar chart?