Пример #1
0
    static wrapText(text, max_width) {
        if (!$.isNumeric(max_width) || max_width <= 0) return;
        var $text = d3.select(text),
            words = text.textContent.split(/\s+/).reverse(),
            word,
            line = [],
            lineNumber = 0,
            lineHeight = text.getBBox().height, // px
            x = $text.attr('x'),
            y = $text.attr('y'),
            tspan = $text
                .text(null)
                .append('tspan')
                .attr('x', x)
                .attr('y', y);

        while ((word = words.pop())) {
            line.push(word);
            tspan.text(line.join(' '));
            if (tspan.node().getComputedTextLength() > max_width && line.length > 1) {
                line.pop();
                tspan.text(line.join(' '));
                line = [word];
                tspan = $text
                    .append('tspan')
                    .attr('x', x)
                    .attr('y', y)
                    .attr('dy', ++lineNumber * lineHeight + 'px')
                    .text(word);
            }
        }
    }
Пример #2
0
    getSD() {
        var n = $('#id_form-0-n').val(),
            varType = $('#id_variance_type').val(),
            variance = $('#id_form-0-variance').val(),
            val = NaN;

        switch (varType) {
            case '1': //SD
                val = variance;
                break;
            case '2': //SE
                if ($.isNumeric(variance) && $.isNumeric(n)) {
                    val = Math.round(variance * Math.sqrt(n));
                }
        }
        return val;
    }
Пример #3
0
 function getOptionIndex(option, options) {
     var index;
     if ($.isNumeric(option)) { // 如果是索引
         index = option;
     } else if (typeof option === 'string') { // 如果是选择器
         index = options.index(options.parent().find(option));
     } else { // 如果是 DOM
         index = options.index(option);
     }
     return index;
 }
Пример #4
0
 _calculate_stdev(eg) {
     // stdev is required for plotting; calculate if SE is specified
     var convert = this.data.data_type === 'C' && parseInt(this.data.variance_type, 10) === 2;
     if (convert) {
         if ($.isNumeric(eg.n)) {
             eg.stdev = eg.variance * Math.sqrt(eg.n);
         } else {
             eg.stdev = undefined;
         }
     } else {
         eg.stdev = eg.variance;
     }
 }
Пример #5
0
 function parseStartDay(startDay) {
     startDay = (startDay || 0).toString().toLowerCase();
     if ($.isNumeric(startDay)) {
         startDay = parseInt(startDay, 10);
         return startDay;
     }
     for (var i = 0; i < DAYS.length; i++) {
         if (DAYS[i].indexOf(startDay) === 0) {
             startDay = i;
             break;
         }
     }
     return startDay;
 }
Пример #6
0
			$('button[type="submit"]').on("click", function(e) {
				var name = $('input[name="name"]').val(),
					chorder = $('input[name="chorder"]').val()
					ctype = $('select[name="ctype"]');

				if ($('option:selected', ctype).val() == '0') {
					ctype.next().removeClass("hide");
					ctype.get(0).focus();
					return false;
				}

				if (name.length === 0 || name.length > 32) {
					$('input[name="name"]').next().removeClass("hide");
					return false;
				}

				if (!$.isNumeric(chorder)) {
					$('input[name="chorder"]').next().removeClass("hide");
					return false;
				}

				return true;
			});
Пример #7
0
 var bars = this.values.filter(function(v) {
         return $.isNumeric(v.y_lower) && $.isNumeric(v.y_upper);
     }),