quadratic-curve

Rounded corners on chartJS v.2 - bar charts (with negative values)

浪尽此生 提交于 2020-03-23 07:48:11
问题 I'm styling some chartjs bar charts which need rounded corners at the bar's values (not their base), In most cases this means rounded corners at the top of the bar's however there are also instances where the bars have negative values. I've used the answer here: How to create rounded bars for Bar Chart.js v2? provided by jordanwillis (https://stackoverflow.com/users/7581592/jordanwillis) which works great when values are positive but not when values are negative. See attached example: bars

How to create prediction line for Quadratic Model

蹲街弑〆低调 提交于 2020-01-05 04:19:10
问题 I am trying to create a quadratic prediction line for a quadratic model. I am using the Auto dataset that comes with R. I had no trouble creating the prediction line for a linear model. However, the quadratic model yields crazy looking lines. Here is my code. # Linear Model plot(Auto$horsepower, Auto$mpg, main = "MPG versus Horsepower", pch = 20) lin_mod = lm(mpg ~ horsepower, data = Auto) lin_pred = predict(lin_mod) lines( Auto$horsepower, lin_pred, col = "blue", lwd = 2 ) # The Quadratic

How to draw a graph using parbola equation

大兔子大兔子 提交于 2019-12-10 11:52:12
问题 I am trying to create a graph using parabola equation ( y=x*x ). But I am bit confused to calculate the value for control point. How should I calculate the control point value. My JavaScript function: function drawParabola() { ctx.beginPath(); for(i=-2;i<=2;i++) { //formual y= x * x; y = i * i; x = i; if (i == -2) { ctx.moveTo((5 + x) * 30, Math.abs((-5 + y)) * 30); } else { //ctx.lineTo((5 + x) * 30, Math.abs((-5 + y)) * 30); context.quadraticCurveTo(**?**, **?**, (5 + x) * 30, Math.abs((-5