MCPcopy Index your code
hub / github.com/plotly/plotly.js / getMarkerAngle

Function getMarkerAngle

src/components/drawing/index.js:1864–1969  ·  view source on GitHub ↗
(d, trace)

Source from the content-addressed store, hash-verified

1862var previousTraceUid;
1863
1864function getMarkerAngle(d, trace) {
1865 var angle = d.ma;
1866
1867 if (angle === undefined) {
1868 angle = trace.marker.angle;
1869 if (!angle || Lib.isArrayOrTypedArray(angle)) {
1870 angle = 0;
1871 }
1872 }
1873
1874 var x, y;
1875 var ref = trace.marker.angleref;
1876 if (ref === 'previous' || ref === 'north') {
1877 if (trace._geo) {
1878 var p = trace._geo.project(d.lonlat);
1879 x = p[0];
1880 y = p[1];
1881 } else {
1882 var xa = trace._xA;
1883 var ya = trace._yA;
1884 if (xa && ya) {
1885 x = xa.c2p(d.x);
1886 y = ya.c2p(d.y);
1887 } else {
1888 // case of legends
1889 return 90;
1890 }
1891 }
1892
1893 if (trace._geo) {
1894 var lon = d.lonlat[0];
1895 var lat = d.lonlat[1];
1896
1897 var north = trace._geo.project([
1898 lon,
1899 lat + 1e-5 // epsilon
1900 ]);
1901
1902 var east = trace._geo.project([
1903 lon + 1e-5, // epsilon
1904 lat
1905 ]);
1906
1907 var u = atan2(east[1] - y, east[0] - x);
1908
1909 var v = atan2(north[1] - y, north[0] - x);
1910
1911 var t;
1912 if (ref === 'north') {
1913 t = (angle / 180) * Math.PI;
1914 // To use counter-clockwise angles i.e.
1915 // East: 90, West: -90
1916 // to facilitate wind visualisations
1917 // in future we should use t = -t here.
1918 } else if (ref === 'previous') {
1919 var lon1 = (lon / 180) * Math.PI;
1920 var lat1 = (lat / 180) * Math.PI;
1921 var lon2 = (previousLon / 180) * Math.PI;

Callers 1

index.jsFile · 0.85

Calls 1

rotateFunction · 0.70

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…