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

Function calcLevels

src/components/colorbar/draw.js:902–951  ·  view source on GitHub ↗
(gd, opts, zrange)

Source from the content-addressed store, hash-verified

900}
901
902function calcLevels(gd, opts, zrange) {
903 var levelsIn = opts._levels;
904 var lineLevels = [];
905 var fillLevels = [];
906 var l;
907 var i;
908
909 var l0 = levelsIn.end + levelsIn.size / 100;
910 var ls = levelsIn.size;
911 var zr0 = (1.001 * zrange[0] - 0.001 * zrange[1]);
912 var zr1 = (1.001 * zrange[1] - 0.001 * zrange[0]);
913
914 for(i = 0; i < 1e5; i++) {
915 l = levelsIn.start + i * ls;
916 if(ls > 0 ? (l >= l0) : (l <= l0)) break;
917 if(l > zr0 && l < zr1) lineLevels.push(l);
918 }
919
920 if(opts._fillgradient) {
921 fillLevels = [0];
922 } else if(typeof opts._fillcolor === 'function') {
923 var fillLevelsIn = opts._filllevels;
924
925 if(fillLevelsIn) {
926 l0 = fillLevelsIn.end + fillLevelsIn.size / 100;
927 ls = fillLevelsIn.size;
928 for(i = 0; i < 1e5; i++) {
929 l = fillLevelsIn.start + i * ls;
930 if(ls > 0 ? (l >= l0) : (l <= l0)) break;
931 if(l > zrange[0] && l < zrange[1]) fillLevels.push(l);
932 }
933 } else {
934 fillLevels = lineLevels.map(function(v) {
935 return v - levelsIn.size / 2;
936 });
937 fillLevels.push(fillLevels[fillLevels.length - 1] + levelsIn.size);
938 }
939 } else if(opts._fillcolor && typeof opts._fillcolor === 'string') {
940 // doesn't matter what this value is, with a single value
941 // we'll make a single fill rect covering the whole bar
942 fillLevels = [0];
943 }
944
945 if(levelsIn.size < 0) {
946 lineLevels.reverse();
947 fillLevels.reverse();
948 }
949
950 return {line: lineLevels, fill: fillLevels};
951}
952
953function mockColorBarAxis(gd, opts, zrange) {
954 var fullLayout = gd._fullLayout;

Callers 1

drawColorBarFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…