MCPcopy Create free account
hub / github.com/adobe/leonardo / chart

Function chart

docs/ui/src/js/createChart.js:73–261  ·  view source on GitHub ↗
(selection)

Source from the content-addressed store, hash-verified

71 ylabel = 'Y Axis Label';
72
73 function chart(selection) {
74 selection.each(function (datasets) {
75 // If no min/max defined, base on min/max from data
76 if (yMin == undefined) {
77 yMin = d3.min(datasets, function (d) {
78 return d3.min(d.y);
79 });
80 }
81 if (yMax == undefined) {
82 yMax = d3.max(datasets, function (d) {
83 return d3.max(d.y);
84 });
85 }
86 //
87 // Create the plot.
88 //
89 let marginBottom = 16;
90 let marginLeft = dest === `#sequentialRGBchart` || dest === '#divergingRGBchart' || dest === '#RGBchart' ? 0 : 36;
91
92 let margin = {
93 top: 8,
94 right: 8,
95 bottom: marginBottom,
96 left: marginLeft
97 };
98
99 let innerwidth = width - margin.left - margin.right;
100 let innerheight = height - margin.top - margin.bottom;
101
102 let x_scale = d3
103 .scaleLinear()
104 .range([0, innerwidth])
105 .domain([
106 d3.min(datasets, function (d) {
107 return d3.min(d.x);
108 }),
109 d3.max(datasets, function (d) {
110 return d3.max(d.x);
111 })
112 ]);
113
114 let y_scale = d3.scaleLinear().range([innerheight, 0]).domain([yMin, yMax]);
115
116 let color_scale;
117 if (!visColors) {
118 color_scale = d3.scaleOrdinal(d3.schemeCategory10).domain(d3.range(datasets.length));
119 } else {
120 color_scale = () => {
121 return visColors;
122 };
123 }
124 let x_axis = d3.axisBottom(x_scale);
125
126 let y_axis = d3.axisLeft(y_scale);
127
128 let x_grid = d3.axisBottom(x_scale).tickSize(-innerheight).tickSizeOuter(0).tickFormat('');
129
130 if (finiteScale) {

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected