I am using chart.js for generating line chart. Its works me successfully. But I need to draw a circle or point at Intersection and draw a line towards "X" axis. Can you please any one help me to get this?

Thanks in advance.

解决方案

The main points to achieve this with chartjs (without being an chartjs expert by any means) would be:

Method 1 - Math

Step 1

Unless you can get a processed point array from chartjs' internals, you would have to, as chartjs uses Bezier curves to draw the graphs, manually convert your point data set into a new point array representing the drawn line.

You would also have to consider scale the same way as chartjs does. As canvas does not provide the points for its Bezier method, you will have to calculate them

Have in mind though: you can not just use some random control points - you will have to replicate these too for the curve the same way chartjs does, so you need to use

Step 2

When both lines are in "Bezier form" you will have to limit the range you want to search by finding which segments of the lines are covering the range you want to check them against.

Do to this using line.x1 <= range.x1 <= line.x2 and the same for range.x2 of the range you want to search (the y axis is not important in this step).

You should end up having two arrays with line segments that matches the range.

(of course, if you don't need to reuse the curves and only need a single segment, you can just find the segments in step 1 and use that for this step).

Step 3

Now you need to loop through array one.

For the current segment in array one, you need to test against all the segments in array two doing intersection test using a

Final

Now you can extract the intersecting point (if any) and plot it to chartjs' canvas (and congratulation, you are also halfway to your own chart widget :P ).

Method 2 - Brute Force

Step 1

Get the bitmap of the canvas.

Step 2

Define a range you want to search for intersection

Calculate the composed color where the two lines meet. This will be the color you search for (you can do a pre-step instead, locating a known intersection and read the pixel value from that point).

Step 3

Scan line by line (vertically) and test each pixel for color values. You need to use a tolerance range (+/- t%) as the canvas pixels are integer values while your result from mixing is a floating point value.

Final

When a pixel has been found add a delta to the value to compensate for line width. Plot to canvas.

js求两圆交点_Chart.js找到交点Point并绘制一个圆相关推荐

  1. c语言求出两个最大素数,求两个正整数的最大公约数      思路:这是一个很基本的问题,最常见的就是两种方法,辗转相除法和辗转相减法。通式分别为 f(x, y) = f(y, x%y...

    求两个正整数的最大公约数 思路:这是一个很基本的问题,最常见的就是两种方法,辗转相除法和辗转相减法.通式分别为 f(x, y) = f(y, x%y), f(x, y) = f(y, x - y) ( ...

  2. java定义一个类计算圆的半径,C++编程:定义一个圆类要求属性为半径,操作为计算圆的周长和面积...,java编程:定义一个圆类,属性为半径,方法为对输入的半径计...

    导航:网站首页 > C++编程:定义一个圆类要求属性为半径,操作为计算圆的周长和面积...,java编程:定义一个圆类,属性为半径,方法为对输入的半径计 C++编程:定义一个圆类要求属性为半径, ...

  3. 如何绘制一个圆的不同方法技巧

    之前和大家分享了很多不同的CAD制图技 巧,这对于我们日常的制图工作很有帮助.若是一个CAD制图初学的小伙伴,该如何简单绘制一个圆呢?今天就和初学CAD制图的小伙伴们分享一下,如何绘制一个圆的不同方法 ...

  4. js求两圆交点_详解js实现线段交点的三种算法

    本文讲的内容都很初级, 主要是面向和我一样的初学者, 所以请各位算法帝们轻拍啊 引用 已知线段1(a,b) 和线段2(c,d) ,其中a b c d为端点, 求线段交点p .(平行或共线视作不相交) ...

  5. js求两圆交点_如何求两个圆的交点坐标,请举例

    展开全部 将两个圆62616964757a686964616fe4b893e5b19e31333431363563的方程相减,就消掉了x²,y²项,剩下一个关于x, y的一次方程,可解得y=kx+b. ...

  6. js求两圆交点_谈谈求线段交点的几种算法(js实现,完整版)

    "求线段交点"是一种非常基础的几何计算, 在很多游戏中都会被使用到. 下面我就现学现卖的把最近才学会的一些"求线段交点"的算法总结一下, 希望对大家有所帮助. ...

  7. three.js 求两个vector3 的夹角_初中数学:动点问题-阿氏圆最值模型(2),求PD-1/2PC的最大值...

    动点问题中的阿氏圆最值模型是初中数学的难点,优秀的学生是必须要会的,这类题目的解题方法就在于构造比例线段,然后求最值. 阿氏圆最小值的解法在这里:初中数学:动点问题-阿氏圆最值模型(1) 阿氏圆最值模 ...

  8. js 求两个日期之间相差天数

    //求两个日期之间的相差天数function daysBetween(DateOne, DateTwo) {var OneMonth = DateOne.substring(5, DateOne.la ...

  9. 求两个相交的线性函数的交点的Python程序

    分别已知两个函数上的两个不同的点,求两个线性函数的交点 from sympy import * x = symbols('x') #求两个函数的交点 x1 = 1 x2 = -2 #第一个函数过的两点 ...

  10. 【C语言】求两个整数的最大公约数和最小公倍数,用一个函数求最大公约数。用另一个函数根据求出的最大公约数求最小公倍数。

    程序如下.思路:编写一个有返回值的函数,使用辗转相除法求两数最大公约数:再编写一个有返回值的函数根据公式(最小公倍数=两数之积除以两数的最大公约数)求两数最小公倍数. #include<stdi ...

最新文章

  1. matlab设计pss参考信号,[OAI][Layer1]PSS/SSS procedure
  2. 页面乱码问题的解决方案
  3. 如何导出SAP的数据表字段和字段描述
  4. 关于meta的各种用处以及移动端的常见问题
  5. SpringBoot2 集成 xxl-job任务调度中心_路由策略
  6. 解决Git Log在IDEA中乱码的问题
  7. ant a-table 表格数据同步
  8. 解密中国人自己的操作系统DIM-SUM
  9. 搭建完全分布式的hadoop[转]
  10. 【图像分割】基于Matlab Tsallis熵算法灰度图像分割【含Matlab源码 715期】
  11. GNSS NMEA-0183 协议
  12. ISP(六) 空间域图像变换(图像反转、对数变换、幂次变换、分段线性变换、直方图均衡与匹配)
  13. 概率论复习大纲 | 速成
  14. HBuilderx连接微信开发者工具
  15. 【笔记】SQL查询语句的基本使用方法
  16. AMBA总线概述——AHB、APB、AXI
  17. 100种乡村旅游盈利方式
  18. 【基于Java+MySQL等技术的企业员工信息管理系统设计与实现】(源代码+数据库+论文+PPT+视频讲解部署 获取)
  19. 因果发现工具 Causal Discovery Toolbox(cdt)安装指南
  20. 【大数据实验】06:MapReduce操作

热门文章

  1. 操作系统-进程同步与互斥易混点
  2. Jmeter之测试片段和模块控制器应用
  3. 【Python】提升Python程序性能的好习惯
  4. Nginx的平滑升级记录---适用于编译安装的Nginx
  5. 《剑指offer》第五十三题(数组中数值和下标相等的元素)
  6. JAVA的BIT数组
  7. Hibernate merge和update的区别
  8. struts2整合uploadify插件怎样传参数
  9. 蓝桥杯第六届省赛JAVA真题----打印菱形
  10. 回溯法在解决八皇后问题中的应用