@cryptotaxi247 / netdata-1 / commits / 6ce41e0ea

split initialization in 2 parts: early and late initialization; early is required even if the chart is never going to be rendered; late is required for the chart to be rendered

Costa Tsaousis (ktsaou) committed Jun 4, 2017 at 21:15 UTC 6ce41e0ea5a498cd820120c08d81393c0699ff17
1 file changed +208 -178
web/dashboard.js
+208 -178
@@ -602,11 +602,11 @@ var NETDATA = window.NETDATA || {};
602 // we have to cancel pending requests too
603
604 while (len--) {
605 - if (targets[len]._updating === true) {
605 + if (targets[len].fetching_data === true) {
606 if (typeof targets[len].xhr !== 'undefined') {
607 targets[len].xhr.abort();
608 targets[len].running = false;
609 - targets[len]._updating = false;
609 + targets[len].fetching_data = false;
610 }
611 targets[len].isVisible();
612 }
@@ -940,8 +940,9 @@ var NETDATA = window.NETDATA || {};
940 // element data attributes
941
942 NETDATA.dataAttribute = function(element, attribute, def) {
943 - if(element.hasAttribute('data-' + attribute) === true) {
944 - var data = element.getAttribute('data-' + attribute);
943 + var key = 'data-' + attribute.toString();
944 + if(element.hasAttribute(key) === true) {
945 + var data = element.getAttribute(key);
946
947 if(data === 'true') return true;
948 if(data === 'false') return false;
@@ -958,6 +959,28 @@ var NETDATA = window.NETDATA || {};
959 else return def;
960 };
961
962 + NETDATA.dataAttributeBoolean = function(element, attribute, def) {
963 + var value = NETDATA.dataAttribute(element, attribute, def);
964 +
965 + if(value === true || value === false)
966 + return value;
967 +
968 + if(typeof(value) === 'string') {
969 + if(value === 'yes' || value === 'on')
970 + return true;
971 +
972 + if(value === '' || value === 'no' || value === 'off' || value === 'null')
973 + return false;
974 +
975 + return def;
976 + }
977 +
978 + if(typeof(value) === 'number')
979 + return value !== 0;
980 +
981 + return def;
982 + };
983 +
984 // ----------------------------------------------------------------------------------------------------------------
985 // commonMin & commonMax
986
@@ -1466,6 +1489,9 @@ var NETDATA = window.NETDATA || {};
1489 // all private functions should use 'that', instead of 'this'
1490 var that = this;
1491
1492 + // ============================================================================================================
1493 + // ERROR HANDLING
1494 +
1495 /* error() - private
1496 * show an error instead of the chart
1497 */
@@ -1488,12 +1514,19 @@ var NETDATA = window.NETDATA || {};
1514 console.log(this.id + ' (' + this.library_name + ' ' + this.uuid + '): ' + msg);
1515 };
1516
1517 +
1518 + // ============================================================================================================
1519 + // EARLY INITIALIZATION
1520 +
1521 + // These are variables that should exist even if the chart is never to be rendered.
1522 + // Be careful what you add here - there may be thousands of charts on the page.
1523 +
1524 // GUID - a unique identifier for the chart
1525 this.uuid = NETDATA.guid();
1526
1527 // string - the name of chart
1495 - this.id = NETDATA.dataAttribute(this.element, 'netdata', null);
1496 - if(this.id === null) {
1528 + this.id = NETDATA.dataAttribute(this.element, 'netdata', undefined);
1529 + if(typeof this.id === 'undefined') {
1530 error("netdata elements need data-netdata");
1531 return;
1532 }
@@ -1516,92 +1549,24 @@ var NETDATA = window.NETDATA || {};
1549 });
1550 }
1551
1519 - // string - the netdata server URL, without any path
1520 - this.host = NETDATA.dataAttribute(this.element, 'host', NETDATA.chartDefaults.host);
1521 -
1522 - // make sure the host does not end with /
1523 - // all netdata API requests use absolute paths
1524 - while(this.host.slice(-1) === '/')
1525 - this.host = this.host.substring(0, this.host.length - 1);
1526 -
1527 - // string - the grouping method requested by the user
1528 - this.method = NETDATA.dataAttribute(this.element, 'method', NETDATA.chartDefaults.method);
1529 -
1530 - // the time-range requested by the user
1531 - this.after = NETDATA.dataAttribute(this.element, 'after', NETDATA.chartDefaults.after);
1532 - this.before = NETDATA.dataAttribute(this.element, 'before', NETDATA.chartDefaults.before);
1533 -
1534 - // the pixels per point requested by the user
1535 - this.pixels_per_point = NETDATA.dataAttribute(this.element, 'pixels-per-point', 1);
1536 - this.points = NETDATA.dataAttribute(this.element, 'points', null);
1537 -
1538 - // the dimensions requested by the user
1539 - this.dimensions = NETDATA.dataAttribute(this.element, 'dimensions', null);
1540 -
1552 // the chart library requested by the user
1553 this.library_name = NETDATA.dataAttribute(this.element, 'chart-library', NETDATA.chartDefaults.library);
1554
1544 - // how many retries we have made to load chart data from the server
1545 - this.retries_on_data_failures = 0;
1546 -
1547 - // object - the chart library used
1548 - this.library = null;
1549 -
1550 - // color management
1551 - this.colors = null;
1552 - this.colors_assigned = {};
1553 - this.colors_available = null;
1554 - this.colors_custom = null;
1555 -
1556 - // the element already created by the user
1557 - this.element_message = null;
1558 -
1559 - // the element with the chart
1560 - this.element_chart = null;
1561 -
1562 - // the element with the legend of the chart (if created by us)
1563 - this.element_legend = null;
1564 - this.element_legend_childs = {
1565 - hidden: null,
1566 - title_date: null,
1567 - title_time: null,
1568 - title_units: null,
1569 - perfect_scroller: null, // the container to apply perfect scroller to
1570 - series: null
1571 - };
1572 -
1573 - this.chart_url = null; // string - the url to download chart info
1574 - this.chart = null; // object - the chart as downloaded from the server
1575 -
1576 - this.title = NETDATA.dataAttribute(this.element, 'title', null); // the title of the chart
1577 - this.units = NETDATA.dataAttribute(this.element, 'units', null); // the units of the chart dimensions
1578 - this.append_options = NETDATA.dataAttribute(this.element, 'append-options', null); // additional options to pass to netdata
1579 - this.override_options = NETDATA.dataAttribute(this.element, 'override-options', null); // override options to pass to netdata
1580 -
1581 - this.chart_created = false; // boolean - true when the chart has been created
1582 - this.dom_created = false; // boolean - true when the DOM has been created
1583 - this.running = false; // boolean - true when the chart is being refreshed now
1584 - this.enabled = true; // boolean - is the chart enabled for refresh?
1585 - this.paused = false; // boolean - is the chart paused for any reason?
1586 - this.selected = false; // boolean - is the chart shown a selection?
1587 - this.debug = NETDATA.dataAttribute(this.element, 'debug', false) === true; // boolean - console.log() debug info about this chart
1588 -
1589 - this.netdata_first = 0; // milliseconds - the first timestamp in netdata
1590 - this.netdata_last = 0; // milliseconds - the last timestamp in netdata
1591 - this.requested_after = null; // milliseconds - the timestamp of the request after param
1592 - this.requested_before = null; // milliseconds - the timestamp of the request before param
1593 - this.requested_padding = null;
1594 - this.view_after = 0;
1595 - this.view_before = 0;
1596 -
1597 - this.tmp = {}; // members that can be destroyed to save memory
1598 -
1599 - this.value_decimal_detail = -1;
1600 - var d = NETDATA.dataAttribute(this.element, 'decimal-digits', -1);
1601 - if(typeof d === 'number')
1602 - this.value_decimal_detail = d;
1603 - else if(typeof d !== 'undefined')
1604 - this.log('ignoring decimal-digits value: ' + d.toString());
1555 + // check the requested library is available
1556 + // we don't initialize it here - it will be initialized when
1557 + // this chart will be first used
1558 + if(typeof NETDATA.chartLibraries[this.library_name] === 'undefined') {
1559 + NETDATA.error(402, this.library_name);
1560 + error('chart library "' + this.library_name + '" is not found');
1561 + this.enabled = false;
1562 + }
1563 + else if(NETDATA.chartLibraries[this.library_name].enabled === false) {
1564 + NETDATA.error(403, this.library_name);
1565 + error('chart library "' + this.library_name + '" is not enabled');
1566 + this.enabled = false;
1567 + }
1568 + else
1569 + this.library = NETDATA.chartLibraries[this.library_name];
1570
1571 this.auto = {
1572 name: 'auto',
@@ -1629,41 +1594,140 @@ var NETDATA = window.NETDATA || {};
1594 // auto, pan, zoom
1595 this.current = this.auto;
1596
1632 - // check the requested library is available
1633 - // we don't initialize it here - it will be initialized when
1634 - // this chart will be first used
1635 - if(typeof NETDATA.chartLibraries[this.library_name] === 'undefined') {
1636 - NETDATA.error(402, this.library_name);
1637 - error('chart library "' + this.library_name + '" is not found');
1638 - return;
1639 - }
1640 - else if(NETDATA.chartLibraries[this.library_name].enabled === false) {
1641 - NETDATA.error(403, this.library_name);
1642 - error('chart library "' + this.library_name + '" is not enabled');
1643 - return;
1644 - }
1645 - else
1646 - this.library = NETDATA.chartLibraries[this.library_name];
1597 + this.running = false; // boolean - true when the chart is being refreshed now
1598 + this.enabled = true; // boolean - is the chart enabled for refresh?
1599
1648 - // milliseconds - the time the last refresh took
1649 - this.refresh_dt_ms = 0;
1600
1651 - // if we need to report the rendering speed
1652 - // find the element that needs to be updated
1653 - var refresh_dt_element_name = NETDATA.dataAttribute(this.element, 'dt-element-name', null); // string - the element to print refresh_dt_ms
1601 + // ============================================================================================================
1602 + // PRIVATE FUNCTIONS
1603
1655 - if(refresh_dt_element_name !== null) {
1656 - this.refresh_dt_element = document.getElementById(refresh_dt_element_name) || null;
1657 - }
1658 - else
1659 - this.refresh_dt_element = null;
1604 + // reset the runtime status variables to their defaults
1605 + var runtimeInit = function() {
1606 + that.paused = false; // boolean - is the chart paused for any reason?
1607 + that.selected = false; // boolean - is the chart shown a selection?
1608
1661 - this.dimensions_visibility = new dimensionsVisibility(this);
1609 + that.chart_created = false; // boolean - is the library.create() been called?
1610 + that.dom_created = false; // boolean - is the chart DOM been created?
1611 + that.fetching_data = false; // boolean - true while we fetch data via ajax
1612
1663 - this._updating = false;
1613 + that.updates_counter = 0; // numeric - the number of refreshes made so far
1614 + that.updates_since_last_unhide = 0; // numeric - the number of refreshes made since the last time the chart was unhidden
1615 + that.updates_since_last_creation = 0; // numeric - the number of refreshes made since the last time the chart was created
1616
1665 - // ============================================================================================================
1666 - // PRIVATE FUNCTIONS
1617 + that.tm = {
1618 + last_initialized: 0, // milliseconds - the timestamp it was last initialized
1619 + last_dom_created: 0, // milliseconds - the timestamp its DOM was last created
1620 + last_mode_switch: 0, // milliseconds - the timestamp it switched modes
1621 +
1622 + last_info_downloaded: 0, // milliseconds - the timestamp we downloaded the chart
1623 + last_updated: 0, // the timestamp the chart last updated with data
1624 + pan_and_zoom_seq: 0, // the sequence number of the global synchronization
1625 + // between chart.
1626 + // Used with NETDATA.globalPanAndZoom.seq
1627 + last_visible_check: 0, // the time we last checked if it is visible
1628 + last_resized: 0, // the time the chart was resized
1629 + last_hidden: 0, // the time the chart was hidden
1630 + last_unhidden: 0, // the time the chart was unhidden
1631 + last_autorefreshed: 0 // the time the chart was last refreshed
1632 + };
1633 +
1634 + that.data = null; // the last data as downloaded from the netdata server
1635 + that.data_url = 'invalid://'; // string - the last url used to update the chart
1636 + that.data_points = 0; // number - the number of points returned from netdata
1637 + that.data_after = 0; // milliseconds - the first timestamp of the data
1638 + that.data_before = 0; // milliseconds - the last timestamp of the data
1639 + that.data_update_every = 0; // milliseconds - the frequency to update the data
1640 +
1641 + that.tmp = {}; // members that can be destroyed to save memory
1642 + };
1643 +
1644 + // initialize all the variables that are required for the chart to be rendered
1645 + var lateInitialization = function() {
1646 + if(typeof that.host !== 'undefined')
1647 + return;
1648 +
1649 + // string - the netdata server URL, without any path
1650 + that.host = NETDATA.dataAttribute(that.element, 'host', NETDATA.chartDefaults.host);
1651 +
1652 + // make sure the host does not end with /
1653 + // all netdata API requests use absolute paths
1654 + while(that.host.slice(-1) === '/')
1655 + that.host = that.host.substring(0, that.host.length - 1);
1656 +
1657 + // string - the grouping method requested by the user
1658 + that.method = NETDATA.dataAttribute(that.element, 'method', NETDATA.chartDefaults.method);
1659 +
1660 + // the time-range requested by the user
1661 + that.after = NETDATA.dataAttribute(that.element, 'after', NETDATA.chartDefaults.after);
1662 + that.before = NETDATA.dataAttribute(that.element, 'before', NETDATA.chartDefaults.before);
1663 +
1664 + // the pixels per point requested by the user
1665 + that.pixels_per_point = NETDATA.dataAttribute(that.element, 'pixels-per-point', 1);
1666 + that.points = NETDATA.dataAttribute(that.element, 'points', null);
1667 +
1668 + // the dimensions requested by the user
1669 + that.dimensions = NETDATA.dataAttribute(that.element, 'dimensions', null);
1670 +
1671 + that.title = NETDATA.dataAttribute(that.element, 'title', null); // the title of the chart
1672 + that.units = NETDATA.dataAttribute(that.element, 'units', null); // the units of the chart dimensions
1673 + that.append_options = NETDATA.dataAttribute(that.element, 'append-options', null); // additional options to pass to netdata
1674 + that.override_options = NETDATA.dataAttribute(that.element, 'override-options', null); // override options to pass to netdata
1675 +
1676 + that.debug = NETDATA.dataAttributeBoolean(that.element, 'debug', false);
1677 +
1678 + that.value_decimal_detail = -1;
1679 + var d = NETDATA.dataAttribute(that.element, 'decimal-digits', -1);
1680 + if(typeof d === 'number')
1681 + that.value_decimal_detail = d;
1682 + else if(typeof d !== 'undefined')
1683 + that.log('ignoring decimal-digits value: ' + d.toString());
1684 +
1685 + // if we need to report the rendering speed
1686 + // find the element that needs to be updated
1687 + var refresh_dt_element_name = NETDATA.dataAttribute(that.element, 'dt-element-name', null); // string - the element to print refresh_dt_ms
1688 +
1689 + if(refresh_dt_element_name !== null) {
1690 + that.refresh_dt_element = document.getElementById(refresh_dt_element_name) || null;
1691 + }
1692 + else
1693 + that.refresh_dt_element = null;
1694 +
1695 + that.dimensions_visibility = new dimensionsVisibility(that);
1696 +
1697 + that.netdata_first = 0; // milliseconds - the first timestamp in netdata
1698 + that.netdata_last = 0; // milliseconds - the last timestamp in netdata
1699 + that.requested_after = null; // milliseconds - the timestamp of the request after param
1700 + that.requested_before = null; // milliseconds - the timestamp of the request before param
1701 + that.requested_padding = null;
1702 + that.view_after = 0;
1703 + that.view_before = 0;
1704 +
1705 + that.refresh_dt_ms = 0; // milliseconds - the time the last refresh took
1706 +
1707 + // how many retries we have made to load chart data from the server
1708 + that.retries_on_data_failures = 0;
1709 +
1710 + // color management
1711 + that.colors = null;
1712 + that.colors_assigned = {};
1713 + that.colors_available = null;
1714 + that.colors_custom = null;
1715 +
1716 + that.element_message = null; // the element already created by the user
1717 + that.element_chart = null; // the element with the chart
1718 + that.element_legend = null; // the element with the legend of the chart (if created by us)
1719 + that.element_legend_childs = {
1720 + hidden: null,
1721 + title_date: null,
1722 + title_time: null,
1723 + title_units: null,
1724 + perfect_scroller: null, // the container to apply perfect scroller to
1725 + series: null
1726 + };
1727 +
1728 + that.chart_url = null; // string - the url to download chart info
1729 + that.chart = null; // object - the chart as downloaded from the server
1730 + };
1731
1732 var destroyDOM = function() {
1733 if(that.enabled === false) return;
@@ -1712,6 +1776,7 @@ var NETDATA = window.NETDATA || {};
1776
1777 var createDOM = function() {
1778 if(that.enabled === false) return;
1779 + lateInitialization();
1780
1781 destroyDOM();
1782
@@ -1755,40 +1820,7 @@ var NETDATA = window.NETDATA || {};
1820 if(that.enabled === false) return;
1821 if(typeof(force) === 'undefined') force = false;
1822
1758 - that.paused = false;
1759 - that.selected = false;
1760 -
1761 - that.chart_created = false; // boolean - is the library.create() been called?
1762 - that.dom_created = false; // boolean - is the chart DOM been created?
1763 - that.updates_counter = 0; // numeric - the number of refreshes made so far
1764 - that.updates_since_last_unhide = 0; // numeric - the number of refreshes made since the last time the chart was unhidden
1765 - that.updates_since_last_creation = 0; // numeric - the number of refreshes made since the last time the chart was created
1766 -
1767 - that.tm = {
1768 - last_initialized: 0, // milliseconds - the timestamp it was last initialized
1769 - last_dom_created: 0, // milliseconds - the timestamp its DOM was last created
1770 - last_mode_switch: 0, // milliseconds - the timestamp it switched modes
1771 -
1772 - last_info_downloaded: 0, // milliseconds - the timestamp we downloaded the chart
1773 - last_updated: 0, // the timestamp the chart last updated with data
1774 - pan_and_zoom_seq: 0, // the sequence number of the global synchronization
1775 - // between chart.
1776 - // Used with NETDATA.globalPanAndZoom.seq
1777 - last_visible_check: 0, // the time we last checked if it is visible
1778 - last_resized: 0, // the time the chart was resized
1779 - last_hidden: 0, // the time the chart was hidden
1780 - last_unhidden: 0, // the time the chart was unhidden
1781 - last_autorefreshed: 0 // the time the chart was last refreshed
1782 - };
1783 -
1784 - that.data = null; // the last data as downloaded from the netdata server
1785 - that.data_url = 'invalid://'; // string - the last url used to update the chart
1786 - that.data_points = 0; // number - the number of points returned from netdata
1787 - that.data_after = 0; // milliseconds - the first timestamp of the data
1788 - that.data_before = 0; // milliseconds - the last timestamp of the data
1789 - that.data_update_every = 0; // milliseconds - the frequency to update the data
1790 -
1791 - that.tmp = {};
1823 + runtimeInit();
1824
1825 that.tm.last_initialized = Date.now();
1826 that.setMode('auto');
@@ -3276,10 +3308,8 @@ var NETDATA = window.NETDATA || {};
3308 return this.tmp.___hasLegendCache___;
3309
3310 var leg = false;
3279 - if(this.library && this.library.legend(this) === 'right-side') {
3280 - var legend = NETDATA.dataAttribute(this.element, 'legend', 'yes');
3281 - if(legend === 'yes') leg = true;
3282 - }
3311 + if(this.library && this.library.legend(this) === 'right-side')
3312 + leg = NETDATA.dataAttributeBoolean(this.element, 'legend', true);
3313
3314 this.tmp.___hasLegendCache___ = leg;
3315 return leg;
@@ -3530,7 +3560,7 @@ var NETDATA = window.NETDATA || {};
3560 if(this.debug === true)
3561 this.log('updateChart()');
3562
3533 - if(this._updating === true) {
3563 + if(this.fetching_data === true) {
3564 if(this.debug === true)
3565 this.log('I am already updating...');
3566
@@ -3595,7 +3625,7 @@ var NETDATA = window.NETDATA || {};
3625 if(NETDATA.statistics.refreshes_active > NETDATA.statistics.refreshes_active_max)
3626 NETDATA.statistics.refreshes_active_max = NETDATA.statistics.refreshes_active;
3627
3598 - this._updating = true;
3628 + this.fetching_data = true;
3629
3630 this.xhr = $.ajax( {
3631 url: this.data_url,
@@ -3636,7 +3666,7 @@ var NETDATA = window.NETDATA || {};
3666 that.xhr = undefined;
3667
3668 NETDATA.statistics.refreshes_active--;
3639 - that._updating = false;
3669 + that.fetching_data = false;
3670
3671 if(typeof callback === 'function')
3672 return callback();
@@ -4327,9 +4357,9 @@ var NETDATA = window.NETDATA || {};
4357 var chartRangeClip = NETDATA.dataAttribute(state.element, 'sparkline-chartrangeclip', undefined);
4358 var chartRangeMinX = NETDATA.dataAttribute(state.element, 'sparkline-chartrangeminx', undefined);
4359 var chartRangeMaxX = NETDATA.dataAttribute(state.element, 'sparkline-chartrangemaxx', undefined);
4330 - var disableInteraction = NETDATA.dataAttribute(state.element, 'sparkline-disableinteraction', false);
4331 - var disableTooltips = NETDATA.dataAttribute(state.element, 'sparkline-disabletooltips', false);
4332 - var disableHighlight = NETDATA.dataAttribute(state.element, 'sparkline-disablehighlight', false);
4360 + var disableInteraction = NETDATA.dataAttributeBoolean(state.element, 'sparkline-disableinteraction', false);
4361 + var disableTooltips = NETDATA.dataAttributeBoolean(state.element, 'sparkline-disabletooltips', false);
4362 + var disableHighlight = NETDATA.dataAttributeBoolean(state.element, 'sparkline-disablehighlight', false);
4363 var highlightLighten = NETDATA.dataAttribute(state.element, 'sparkline-highlightlighten', 1.4);
4364 var highlightColor = NETDATA.dataAttribute(state.element, 'sparkline-highlightcolor', undefined);
4365 var tooltipContainer = NETDATA.dataAttribute(state.element, 'sparkline-tooltipcontainer', undefined);
@@ -4337,7 +4367,7 @@ var NETDATA = window.NETDATA || {};
4367 var tooltipFormat = NETDATA.dataAttribute(state.element, 'sparkline-tooltipformat', undefined);
4368 var tooltipPrefix = NETDATA.dataAttribute(state.element, 'sparkline-tooltipprefix', undefined);
4369 var tooltipSuffix = NETDATA.dataAttribute(state.element, 'sparkline-tooltipsuffix', ' ' + state.units);
4340 - var tooltipSkipNull = NETDATA.dataAttribute(state.element, 'sparkline-tooltipskipnull', true);
4370 + var tooltipSkipNull = NETDATA.dataAttributeBoolean(state.element, 'sparkline-tooltipskipnull', true);
4371 var tooltipValueLookups = NETDATA.dataAttribute(state.element, 'sparkline-tooltipvaluelookups', undefined);
4372 var tooltipFormatFieldlist = NETDATA.dataAttribute(state.element, 'sparkline-tooltipformatfieldlist', undefined);
4373 var tooltipFormatFieldlistKey = NETDATA.dataAttribute(state.element, 'sparkline-tooltipformatfieldlistkey', undefined);
@@ -4345,7 +4375,7 @@ var NETDATA = window.NETDATA || {};
4375 var numberDigitGroupSep = NETDATA.dataAttribute(state.element, 'sparkline-numberdigitgroupsep', undefined);
4376 var numberDecimalMark = NETDATA.dataAttribute(state.element, 'sparkline-numberdecimalmark', undefined);
4377 var numberDigitGroupCount = NETDATA.dataAttribute(state.element, 'sparkline-numberdigitgroupcount', undefined);
4348 - var animatedZooms = NETDATA.dataAttribute(state.element, 'sparkline-animatedzooms', false);
4378 + var animatedZooms = NETDATA.dataAttributeBoolean(state.element, 'sparkline-animatedzooms', false);
4379
4380 if(spotColor === 'disable') spotColor='';
4381 if(minSpotColor === 'disable') minSpotColor='';
@@ -4596,7 +4626,7 @@ var NETDATA = window.NETDATA || {};
4626 var highlightCircleSize = (NETDATA.chartLibraries.dygraph.isSparkline(state) === true)?3:4;
4627
4628 var smooth = (NETDATA.dygraph.smooth === true)
4599 - ?(NETDATA.dataAttribute(state.element, 'dygraph-smooth', (chart_type === 'line' && NETDATA.chartLibraries.dygraph.isSparkline(state) === false)))
4629 + ?(NETDATA.dataAttributeBoolean(state.element, 'dygraph-smooth', (chart_type === 'line' && NETDATA.chartLibraries.dygraph.isSparkline(state) === false)))
4630 :false;
4631
4632 state.tmp.dygraph_options = {
@@ -4604,8 +4634,8 @@ var NETDATA = window.NETDATA || {};
4634
4635 // leave a few pixels empty on the right of the chart
4636 rightGap: NETDATA.dataAttribute(state.element, 'dygraph-rightgap', 5),
4607 - showRangeSelector: NETDATA.dataAttribute(state.element, 'dygraph-showrangeselector', false),
4608 - showRoller: NETDATA.dataAttribute(state.element, 'dygraph-showroller', false),
4637 + showRangeSelector: NETDATA.dataAttributeBoolean(state.element, 'dygraph-showrangeselector', false),
4638 + showRoller: NETDATA.dataAttributeBoolean(state.element, 'dygraph-showroller', false),
4639 title: NETDATA.dataAttribute(state.element, 'dygraph-title', state.title),
4640 titleHeight: NETDATA.dataAttribute(state.element, 'dygraph-titleheight', 19),
4641 legend: NETDATA.dataAttribute(state.element, 'dygraph-legend', 'always'), // we need this to get selection events
@@ -4613,12 +4643,12 @@ var NETDATA = window.NETDATA || {};
4643 labelsDiv: NETDATA.dataAttribute(state.element, 'dygraph-labelsdiv', state.element_legend_childs.hidden),
4644 labelsDivStyles: NETDATA.dataAttribute(state.element, 'dygraph-labelsdivstyles', { 'fontSize':'1px' }),
4645 labelsDivWidth: NETDATA.dataAttribute(state.element, 'dygraph-labelsdivwidth', state.chartWidth() - 70),
4616 - labelsSeparateLines: NETDATA.dataAttribute(state.element, 'dygraph-labelsseparatelines', true),
4617 - labelsShowZeroValues: NETDATA.dataAttribute(state.element, 'dygraph-labelsshowzerovalues', true),
4646 + labelsSeparateLines: NETDATA.dataAttributeBoolean(state.element, 'dygraph-labelsseparatelines', true),
4647 + labelsShowZeroValues: NETDATA.dataAttributeBoolean(state.element, 'dygraph-labelsshowzerovalues', true),
4648 labelsKMB: false,
4649 labelsKMG2: false,
4620 - showLabelsOnHighlight: NETDATA.dataAttribute(state.element, 'dygraph-showlabelsonhighlight', true),
4621 - hideOverlayOnMouseOut: NETDATA.dataAttribute(state.element, 'dygraph-hideoverlayonmouseout', true),
4650 + showLabelsOnHighlight: NETDATA.dataAttributeBoolean(state.element, 'dygraph-showlabelsonhighlight', true),
4651 + hideOverlayOnMouseOut: NETDATA.dataAttributeBoolean(state.element, 'dygraph-hideoverlayonmouseout', true),
4652 includeZero: NETDATA.dataAttribute(state.element, 'dygraph-includezero', (chart_type === 'stacked')),
4653 xRangePad: NETDATA.dataAttribute(state.element, 'dygraph-xrangepad', 0),
4654 yRangePad: NETDATA.dataAttribute(state.element, 'dygraph-yrangepad', 1),
@@ -4638,16 +4668,16 @@ var NETDATA = window.NETDATA || {};
4668 // A dot is always drawn when a point is "isolated",
4669 // i.e. there is a missing point on either side of it.
4670 // This also controls the size of those dots.
4641 - drawPoints: NETDATA.dataAttribute(state.element, 'dygraph-drawpoints', false),
4671 + drawPoints: NETDATA.dataAttributeBoolean(state.element, 'dygraph-drawpoints', false),
4672
4673 // Draw points at the edges of gaps in the data.
4674 // This improves visibility of small data segments or other data irregularities.
4645 - drawGapEdgePoints: NETDATA.dataAttribute(state.element, 'dygraph-drawgapedgepoints', true),
4646 - connectSeparatedPoints: NETDATA.dataAttribute(state.element, 'dygraph-connectseparatedpoints', false),
4675 + drawGapEdgePoints: NETDATA.dataAttributeBoolean(state.element, 'dygraph-drawgapedgepoints', true),
4676 + connectSeparatedPoints: NETDATA.dataAttributeBoolean(state.element, 'dygraph-connectseparatedpoints', false),
4677 pointSize: NETDATA.dataAttribute(state.element, 'dygraph-pointsize', 1),
4678
4679 // enabling this makes the chart with little square lines
4650 - stepPlot: NETDATA.dataAttribute(state.element, 'dygraph-stepplot', false),
4680 + stepPlot: NETDATA.dataAttributeBoolean(state.element, 'dygraph-stepplot', false),
4681
4682 // Draw a border around graph lines to make crossing lines more easily
4683 // distinguishable. Useful for graphs with many lines.
@@ -4661,11 +4691,11 @@ var NETDATA = window.NETDATA || {};
4691 ),
4692 stackedGraph: NETDATA.dataAttribute(state.element, 'dygraph-stackedgraph', (chart_type === 'stacked')),
4693 stackedGraphNaNFill: NETDATA.dataAttribute(state.element, 'dygraph-stackedgraphnanfill', 'none'),
4664 - drawAxis: NETDATA.dataAttribute(state.element, 'dygraph-drawaxis', true),
4694 + drawAxis: NETDATA.dataAttributeBoolean(state.element, 'dygraph-drawaxis', true),
4695 axisLabelFontSize: NETDATA.dataAttribute(state.element, 'dygraph-axislabelfontsize', 10),
4696 axisLineColor: NETDATA.dataAttribute(state.element, 'dygraph-axislinecolor', NETDATA.themes.current.axis),
4697 axisLineWidth: NETDATA.dataAttribute(state.element, 'dygraph-axislinewidth', 1.0),
4668 - drawGrid: NETDATA.dataAttribute(state.element, 'dygraph-drawgrid', true),
4698 + drawGrid: NETDATA.dataAttributeBoolean(state.element, 'dygraph-drawgrid', true),
4699 gridLinePattern: NETDATA.dataAttribute(state.element, 'dygraph-gridlinepattern', null),
4700 gridLineWidth: NETDATA.dataAttribute(state.element, 'dygraph-gridlinewidth', 1.0),
4701 gridLineColor: NETDATA.dataAttribute(state.element, 'dygraph-gridlinecolor', NETDATA.themes.current.grid),
@@ -5961,7 +5991,7 @@ var NETDATA = window.NETDATA || {};
5991 var strokeColor = NETDATA.dataAttribute(state.element, 'gauge-stroke-color', NETDATA.themes.current.gauge_stroke);
5992 var startColor = NETDATA.dataAttribute(state.element, 'gauge-start-color', state.chartCustomColors()[0]);
5993 var stopColor = NETDATA.dataAttribute(state.element, 'gauge-stop-color', void 0);
5964 - var generateGradient = NETDATA.dataAttribute(state.element, 'gauge-generate-gradient', false);
5994 + var generateGradient = NETDATA.dataAttributeBoolean(state.element, 'gauge-generate-gradient', false);
5995
5996 if(min === null) {
5997 min = NETDATA.commonMin.get(state);