(data, yLabel, xLabel, dest, yMin, yMax, colors, scaleType)
| 289 | } |
| 290 | |
| 291 | function createColorChart(data, yLabel, xLabel, dest, yMin, yMax, colors, scaleType) { |
| 292 | let chartWidth, chartHeight; |
| 293 | const windowWidth = window.innerWidth; |
| 294 | |
| 295 | let adjustedWidth, adjustedHeight; |
| 296 | const maxWidth = 800; |
| 297 | const minWidth = 200; |
| 298 | const windowHeight = window.innerHeight; |
| 299 | |
| 300 | if (dest === `#${scaleType}InterpolationChart` || dest === `#${scaleType}InterpolationChart2` || dest === `#${scaleType}InterpolationChart3`) { |
| 301 | let adjustedWidth = windowWidth - (388 + 34) - 8; // subtract panel width and padding from measurement |
| 302 | let newMaxWidth = 476; |
| 303 | adjustedWidth = adjustedWidth < newMaxWidth ? adjustedWidth : newMaxWidth; |
| 304 | |
| 305 | chartWidth = adjustedWidth; |
| 306 | adjustedHeight = (windowHeight - 332) / 3; |
| 307 | chartHeight = 196; |
| 308 | } else { |
| 309 | let newMaxWidth = 600; |
| 310 | let adjustedWidth = windowWidth - 320 - panelsOffset - 48; // subtract panel width and padding from measurement |
| 311 | let newAdjustedWidth = adjustedWidth < newMaxWidth ? adjustedWidth : newMaxWidth; |
| 312 | |
| 313 | let minHeight = 196; |
| 314 | let dynamicHeight = window.innerHeight / 3 - 80; // subtract heading, tabs height and padding from measurement |
| 315 | adjustedHeight = dynamicHeight < minHeight ? minHeight : dynamicHeight; |
| 316 | |
| 317 | chartWidth = newAdjustedWidth; |
| 318 | chartHeight = adjustedHeight; |
| 319 | } |
| 320 | |
| 321 | // Prevent negative values from being passed to the SVG attributes |
| 322 | // by setting a min width for hte charts. |
| 323 | if (chartWidth < minWidth) chartWidth = minWidth; |
| 324 | |
| 325 | let xy_chart = d3_xy_chart().width(chartWidth).height(chartHeight).xlabel(xLabel).ylabel(yLabel); |
| 326 | |
| 327 | let svg = d3.select(dest).append('svg').datum(data).call(xy_chart); |
| 328 | |
| 329 | function d3_xy_chart() { |
| 330 | let width = chartWidth, |
| 331 | height = chartHeight, |
| 332 | xlabel = 'X Axis Label', |
| 333 | ylabel = 'Y Axis Label'; |
| 334 | |
| 335 | function chart(selection) { |
| 336 | selection.each(function (datasets) { |
| 337 | // If no min/max defined, base on min/max from data |
| 338 | if (yMin == undefined) { |
| 339 | yMin = d3.min(datasets, function (d) { |
| 340 | return d3.min(d.y); |
| 341 | }); |
| 342 | } |
| 343 | if (yMax == undefined) { |
| 344 | yMax = d3.max(datasets, function (d) { |
| 345 | return d3.max(d.y); |
| 346 | }); |
| 347 | } |
| 348 | // |
no test coverage detected