Proyectos de Subversion Moodle

Rev

Rev 1 | Mostrar el archivo completo | | | Autoría | Ultima modificación | Ver Log |

Rev 1 Rev 1441
Línea 1... Línea 1...
1
/*!
1
/*!
2
 * Chart.js v4.4.2
2
 * Chart.js v4.4.7
3
 * https://www.chartjs.org
3
 * https://www.chartjs.org
4
 * (c) 2024 Chart.js Contributors
4
 * (c) 2024 Chart.js Contributors
5
 * Released under the MIT License
5
 * Released under the MIT License
6
 */
6
 */
Línea 75... Línea 75...
75
/**
75
/**
76
 * Returns true if `value` is neither null nor undefined, else returns false.
76
 * Returns true if `value` is neither null nor undefined, else returns false.
77
 * @param value - The value to test.
77
 * @param value - The value to test.
78
 * @since 2.7.0
78
 * @since 2.7.0
79
 */ function isNullOrUndef(value) {
79
 */ function isNullOrUndef(value) {
80
    return value === null || typeof value === 'undefined';
80
    return value === null || value === undefined;
81
}
81
}
82
/**
82
/**
83
 * Returns true if `value` is an array (including typed arrays), else returns false.
83
 * Returns true if `value` is an array (including typed arrays), else returns false.
84
 * @param value - The value to test.
84
 * @param value - The value to test.
85
 * @function
85
 * @function
Línea 1911... Línea 1911...
1911
    };
1911
    };
1912
}
1912
}
1913
function getContainerSize(canvas, width, height) {
1913
function getContainerSize(canvas, width, height) {
1914
    let maxWidth, maxHeight;
1914
    let maxWidth, maxHeight;
1915
    if (width === undefined || height === undefined) {
1915
    if (width === undefined || height === undefined) {
1916
        const container = _getParentNode(canvas);
1916
        const container = canvas && _getParentNode(canvas);
1917
        if (!container) {
1917
        if (!container) {
1918
            width = canvas.clientWidth;
1918
            width = canvas.clientWidth;
1919
            height = canvas.clientHeight;
1919
            height = canvas.clientHeight;
1920
        } else {
1920
        } else {
1921
            const rect = container.getBoundingClientRect(); // this is the border box of the container
1921
            const rect = container.getBoundingClientRect(); // this is the border box of the container
Línea 2114... Línea 2114...
2114
    return Math.round((pixel - halfWidth) * devicePixelRatio) / devicePixelRatio + halfWidth;
2114
    return Math.round((pixel - halfWidth) * devicePixelRatio) / devicePixelRatio + halfWidth;
2115
}
2115
}
2116
/**
2116
/**
2117
 * Clears the entire canvas.
2117
 * Clears the entire canvas.
2118
 */ function clearCanvas(canvas, ctx) {
2118
 */ function clearCanvas(canvas, ctx) {
-
 
2119
    if (!ctx && !canvas) {
-
 
2120
        return;
-
 
2121
    }
2119
    ctx = ctx || canvas.getContext('2d');
2122
    ctx = ctx || canvas.getContext('2d');
2120
    ctx.save();
2123
    ctx.save();
2121
    // canvas.width and canvas.height do not consider the canvas transform,
2124
    // canvas.width and canvas.height do not consider the canvas transform,
2122
    // while clearRect does
2125
    // while clearRect does
2123
    ctx.resetTransform();
2126
    ctx.resetTransform();
Línea 2555... Línea 2558...
2555
    };
2558
    };
2556
}
2559
}
2557
const readKey = (prefix, name)=>prefix ? prefix + _capitalize(name) : name;
2560
const readKey = (prefix, name)=>prefix ? prefix + _capitalize(name) : name;
2558
const needsSubResolver = (prop, value)=>isObject(value) && prop !== 'adapters' && (Object.getPrototypeOf(value) === null || value.constructor === Object);
2561
const needsSubResolver = (prop, value)=>isObject(value) && prop !== 'adapters' && (Object.getPrototypeOf(value) === null || value.constructor === Object);
2559
function _cached(target, prop, resolve) {
2562
function _cached(target, prop, resolve) {
2560
    if (Object.prototype.hasOwnProperty.call(target, prop)) {
2563
    if (Object.prototype.hasOwnProperty.call(target, prop) || prop === 'constructor') {
2561
        return target[prop];
2564
        return target[prop];
2562
    }
2565
    }
2563
    const value = resolve();
2566
    const value = resolve();
2564
    // cache the resolved value
2567
    // cache the resolved value
2565
    target[prop] = value;
2568
    target[prop] = value;
Línea 3766... Línea 3769...
3766
 function getAxisItems(chart, position, axis, intersect, useFinalPosition) {
3769
 function getAxisItems(chart, position, axis, intersect, useFinalPosition) {
3767
    const items = [];
3770
    const items = [];
3768
    const rangeMethod = axis === 'x' ? 'inXRange' : 'inYRange';
3771
    const rangeMethod = axis === 'x' ? 'inXRange' : 'inYRange';
3769
    let intersectsItem = false;
3772
    let intersectsItem = false;
3770
    evaluateInteractionItems(chart, axis, position, (element, datasetIndex, index)=>{
3773
    evaluateInteractionItems(chart, axis, position, (element, datasetIndex, index)=>{
3771
        if (element[rangeMethod](position[axis], useFinalPosition)) {
3774
        if (element[rangeMethod] && element[rangeMethod](position[axis], useFinalPosition)) {
3772
            items.push({
3775
            items.push({
3773
                element,
3776
                element,
3774
                datasetIndex,
3777
                datasetIndex,
3775
                index
3778
                index
3776
            });
3779
            });
Línea 4465... Línea 4468...
4465
    }
4468
    }
4466
 getMaximumSize(canvas, width, height, aspectRatio) {
4469
 getMaximumSize(canvas, width, height, aspectRatio) {
4467
        return getMaximumSize(canvas, width, height, aspectRatio);
4470
        return getMaximumSize(canvas, width, height, aspectRatio);
4468
    }
4471
    }
4469
 isAttached(canvas) {
4472
 isAttached(canvas) {
4470
        const container = _getParentNode(canvas);
4473
        const container = canvas && _getParentNode(canvas);
4471
        return !!(container && container.isConnected);
4474
        return !!(container && container.isConnected);
4472
    }
4475
    }
4473
}
4476
}
Línea 4474... Línea 4477...
4474
 
4477
 
Línea 4778... Línea 4781...
4778
    const singleMode = options.mode === 'single';
4781
    const singleMode = options.mode === 'single';
4779
    let i, ilen, datasetIndex, otherValue;
4782
    let i, ilen, datasetIndex, otherValue;
4780
    if (value === null) {
4783
    if (value === null) {
4781
        return;
4784
        return;
4782
    }
4785
    }
-
 
4786
    let found = false;
4783
    for(i = 0, ilen = keys.length; i < ilen; ++i){
4787
    for(i = 0, ilen = keys.length; i < ilen; ++i){
4784
        datasetIndex = +keys[i];
4788
        datasetIndex = +keys[i];
4785
        if (datasetIndex === dsIndex) {
4789
        if (datasetIndex === dsIndex) {
-
 
4790
            found = true;
4786
            if (options.all) {
4791
            if (options.all) {
4787
                continue;
4792
                continue;
4788
            }
4793
            }
4789
            break;
4794
            break;
4790
        }
4795
        }
4791
        otherValue = stack.values[datasetIndex];
4796
        otherValue = stack.values[datasetIndex];
4792
        if (isNumberFinite(otherValue) && (singleMode || value === 0 || sign(value) === sign(otherValue))) {
4797
        if (isNumberFinite(otherValue) && (singleMode || value === 0 || sign(value) === sign(otherValue))) {
4793
            value += otherValue;
4798
            value += otherValue;
4794
        }
4799
        }
4795
    }
4800
    }
-
 
4801
    if (!found && !options.all) {
-
 
4802
        return 0;
-
 
4803
    }
4796
    return value;
4804
    return value;
4797
}
4805
}
4798
function convertObjectDataToArray(data) {
4806
function convertObjectDataToArray(data, meta) {
-
 
4807
    const { iScale , vScale  } = meta;
-
 
4808
    const iAxisKey = iScale.axis === 'x' ? 'x' : 'y';
-
 
4809
    const vAxisKey = vScale.axis === 'x' ? 'x' : 'y';
4799
    const keys = Object.keys(data);
4810
    const keys = Object.keys(data);
4800
    const adata = new Array(keys.length);
4811
    const adata = new Array(keys.length);
4801
    let i, ilen, key;
4812
    let i, ilen, key;
4802
    for(i = 0, ilen = keys.length; i < ilen; ++i){
4813
    for(i = 0, ilen = keys.length; i < ilen; ++i){
4803
        key = keys[i];
4814
        key = keys[i];
4804
        adata[i] = {
4815
        adata[i] = {
4805
            x: key,
4816
            [iAxisKey]: key,
4806
            y: data[key]
4817
            [vAxisKey]: data[key]
4807
        };
4818
        };
4808
    }
4819
    }
4809
    return adata;
4820
    return adata;
4810
}
4821
}
4811
function isStacked(scale, meta) {
4822
function isStacked(scale, meta) {
Línea 4993... Línea 5004...
4993
 _dataCheck() {
5004
 _dataCheck() {
4994
        const dataset = this.getDataset();
5005
        const dataset = this.getDataset();
4995
        const data = dataset.data || (dataset.data = []);
5006
        const data = dataset.data || (dataset.data = []);
4996
        const _data = this._data;
5007
        const _data = this._data;
4997
        if (isObject(data)) {
5008
        if (isObject(data)) {
-
 
5009
            const meta = this._cachedMeta;
4998
            this._data = convertObjectDataToArray(data);
5010
            this._data = convertObjectDataToArray(data, meta);
4999
        } else if (_data !== data) {
5011
        } else if (_data !== data) {
5000
            if (_data) {
5012
            if (_data) {
5001
                unlistenArrayEvents(_data, this);
5013
                unlistenArrayEvents(_data, this);
5002
                const meta = this._cachedMeta;
5014
                const meta = this._cachedMeta;
5003
                clearStacks(meta);
5015
                clearStacks(meta);
Línea 5030... Línea 5042...
5030
            meta.stack = dataset.stack;
5042
            meta.stack = dataset.stack;
5031
        }
5043
        }
5032
        this._resyncElements(resetNewElements);
5044
        this._resyncElements(resetNewElements);
5033
        if (stackChanged || oldStacked !== meta._stacked) {
5045
        if (stackChanged || oldStacked !== meta._stacked) {
5034
            updateStacks(this, meta._parsed);
5046
            updateStacks(this, meta._parsed);
-
 
5047
            meta._stacked = isStacked(meta.vScale, meta);
5035
        }
5048
        }
5036
    }
5049
    }
5037
 configure() {
5050
 configure() {
5038
        const config = this.chart.config;
5051
        const config = this.chart.config;
5039
        const scopeKeys = config.datasetScopeKeys(this._type);
5052
        const scopeKeys = config.datasetScopeKeys(this._type);
Línea 7544... Línea 7557...
7544
        }
7557
        }
7545
    }
7558
    }
7546
    return false;
7559
    return false;
7547
}
7560
}
Línea 7548... Línea 7561...
7548
 
7561
 
Línea 7549... Línea 7562...
7549
var version = "4.4.2";
7562
var version = "4.4.7";
7550
 
7563
 
7551
const KNOWN_POSITIONS = [
7564
const KNOWN_POSITIONS = [
7552
    'top',
7565
    'top',
Línea 8076... Línea 8089...
8076
    }
8089
    }
8077
    draw() {
8090
    draw() {
8078
        let i;
8091
        let i;
8079
        if (this._resizeBeforeDraw) {
8092
        if (this._resizeBeforeDraw) {
8080
            const { width , height  } = this._resizeBeforeDraw;
8093
            const { width , height  } = this._resizeBeforeDraw;
8081
            this._resize(width, height);
-
 
8082
            this._resizeBeforeDraw = null;
8094
            this._resizeBeforeDraw = null;
-
 
8095
            this._resize(width, height);
8083
        }
8096
        }
8084
        this.clear();
8097
        this.clear();
8085
        if (this.width <= 0 || this.height <= 0) {
8098
        if (this.width <= 0 || this.height <= 0) {
8086
            return;
8099
            return;
8087
        }
8100
        }
Línea 8844... Línea 8857...
8844
 _getStacks(last, dataIndex) {
8857
 _getStacks(last, dataIndex) {
8845
        const { iScale  } = this._cachedMeta;
8858
        const { iScale  } = this._cachedMeta;
8846
        const metasets = iScale.getMatchingVisibleMetas(this._type).filter((meta)=>meta.controller.options.grouped);
8859
        const metasets = iScale.getMatchingVisibleMetas(this._type).filter((meta)=>meta.controller.options.grouped);
8847
        const stacked = iScale.options.stacked;
8860
        const stacked = iScale.options.stacked;
8848
        const stacks = [];
8861
        const stacks = [];
-
 
8862
        const currentParsed = this._cachedMeta.controller.getParsed(dataIndex);
-
 
8863
        const iScaleValue = currentParsed && currentParsed[iScale.axis];
8849
        const skipNull = (meta)=>{
8864
        const skipNull = (meta)=>{
8850
            const parsed = meta.controller.getParsed(dataIndex);
8865
            const parsed = meta._parsed.find((item)=>item[iScale.axis] === iScaleValue);
8851
            const val = parsed && parsed[meta.vScale.axis];
8866
            const val = parsed && parsed[meta.vScale.axis];
8852
            if (isNullOrUndef(val) || isNaN(val)) {
8867
            if (isNullOrUndef(val) || isNaN(val)) {
8853
                return true;
8868
                return true;
8854
            }
8869
            }
8855
        };
8870
        };
Línea 8984... Línea 8999...
8984
        const vScale = meta.vScale;
8999
        const vScale = meta.vScale;
8985
        const rects = meta.data;
9000
        const rects = meta.data;
8986
        const ilen = rects.length;
9001
        const ilen = rects.length;
8987
        let i = 0;
9002
        let i = 0;
8988
        for(; i < ilen; ++i){
9003
        for(; i < ilen; ++i){
8989
            if (this.getParsed(i)[vScale.axis] !== null) {
9004
            if (this.getParsed(i)[vScale.axis] !== null && !rects[i].hidden) {
8990
                rects[i].draw(this._ctx);
9005
                rects[i].draw(this._ctx);
8991
            }
9006
            }
8992
        }
9007
        }
8993
    }
9008
    }
8994
}
9009
}
Línea 10176... Línea 10191...
10176
            'outerRadius',
10191
            'outerRadius',
10177
            'circumference'
10192
            'circumference'
10178
        ], useFinalPosition);
10193
        ], useFinalPosition);
10179
        const rAdjust = (this.options.spacing + this.options.borderWidth) / 2;
10194
        const rAdjust = (this.options.spacing + this.options.borderWidth) / 2;
10180
        const _circumference = valueOrDefault(circumference, endAngle - startAngle);
10195
        const _circumference = valueOrDefault(circumference, endAngle - startAngle);
-
 
10196
        const nonZeroBetween = _angleBetween(angle, startAngle, endAngle) && startAngle !== endAngle;
10181
        const betweenAngles = _circumference >= TAU || _angleBetween(angle, startAngle, endAngle);
10197
        const betweenAngles = _circumference >= TAU || nonZeroBetween;
10182
        const withinRadius = _isBetween(distance, innerRadius + rAdjust, outerRadius + rAdjust);
10198
        const withinRadius = _isBetween(distance, innerRadius + rAdjust, outerRadius + rAdjust);
10183
        return betweenAngles && withinRadius;
10199
        return betweenAngles && withinRadius;
10184
    }
10200
    }
10185
    getCenterPoint(useFinalPosition) {
10201
    getCenterPoint(useFinalPosition) {
10186
        const { x , y , startAngle , endAngle , innerRadius , outerRadius  } = this.getProps([
10202
        const { x , y , startAngle , endAngle , innerRadius , outerRadius  } = this.getProps([
Línea 11567... Línea 11583...
11567
        return;
11583
        return;
11568
    }
11584
    }
11569
    ctx.save();
11585
    ctx.save();
11570
    ctx.strokeStyle = color;
11586
    ctx.strokeStyle = color;
11571
    ctx.lineWidth = lineWidth;
11587
    ctx.lineWidth = lineWidth;
11572
    ctx.setLineDash(borderOpts.dash);
11588
    ctx.setLineDash(borderOpts.dash || []);
11573
    ctx.lineDashOffset = borderOpts.dashOffset;
11589
    ctx.lineDashOffset = borderOpts.dashOffset;
11574
    ctx.beginPath();
11590
    ctx.beginPath();
11575
    pathRadiusLine(scale, radius, circular, labelCount);
11591
    pathRadiusLine(scale, radius, circular, labelCount);
11576
    ctx.closePath();
11592
    ctx.closePath();
11577
    ctx.stroke();
11593
    ctx.stroke();
Línea 11771... Línea 11787...
11771
                }
11787
                }
11772
                ctx.lineWidth = lineWidth;
11788
                ctx.lineWidth = lineWidth;
11773
                ctx.strokeStyle = color;
11789
                ctx.strokeStyle = color;
11774
                ctx.setLineDash(optsAtIndex.borderDash);
11790
                ctx.setLineDash(optsAtIndex.borderDash);
11775
                ctx.lineDashOffset = optsAtIndex.borderDashOffset;
11791
                ctx.lineDashOffset = optsAtIndex.borderDashOffset;
11776
                offset = this.getDistanceFromCenterForValue(opts.ticks.reverse ? this.min : this.max);
11792
                offset = this.getDistanceFromCenterForValue(opts.reverse ? this.min : this.max);
11777
                position = this.getPointPosition(i, offset);
11793
                position = this.getPointPosition(i, offset);
11778
                ctx.beginPath();
11794
                ctx.beginPath();
11779
                ctx.moveTo(this.xCenter, this.yCenter);
11795
                ctx.moveTo(this.xCenter, this.yCenter);
11780
                ctx.lineTo(position.x, position.y);
11796
                ctx.lineTo(position.x, position.y);
11781
                ctx.stroke();
11797
                ctx.stroke();
Línea 12418... Línea 12434...
12418
    return false;
12434
    return false;
12419
}
12435
}
12420
function containsColorsDefinition(descriptor) {
12436
function containsColorsDefinition(descriptor) {
12421
    return descriptor && (descriptor.borderColor || descriptor.backgroundColor);
12437
    return descriptor && (descriptor.borderColor || descriptor.backgroundColor);
12422
}
12438
}
-
 
12439
function containsDefaultColorsDefenitions() {
-
 
12440
    return defaults.borderColor !== 'rgba(0,0,0,0.1)' || defaults.backgroundColor !== 'rgba(0,0,0,0.1)';
-
 
12441
}
12423
var plugin_colors = {
12442
var plugin_colors = {
12424
    id: 'colors',
12443
    id: 'colors',
12425
    defaults: {
12444
    defaults: {
12426
        enabled: true,
12445
        enabled: true,
12427
        forceOverride: false
12446
        forceOverride: false
Línea 12430... Línea 12449...
12430
        if (!options.enabled) {
12449
        if (!options.enabled) {
12431
            return;
12450
            return;
12432
        }
12451
        }
12433
        const { data: { datasets  } , options: chartOptions  } = chart.config;
12452
        const { data: { datasets  } , options: chartOptions  } = chart.config;
12434
        const { elements  } = chartOptions;
12453
        const { elements  } = chartOptions;
12435
        if (!options.forceOverride && (containsColorsDefinitions(datasets) || containsColorsDefinition(chartOptions) || elements && containsColorsDefinitions(elements))) {
12454
        const containsColorDefenition = containsColorsDefinitions(datasets) || containsColorsDefinition(chartOptions) || elements && containsColorsDefinitions(elements) || containsDefaultColorsDefenitions();
-
 
12455
        if (!options.forceOverride && containsColorDefenition) {
12436
            return;
12456
            return;
12437
        }
12457
        }
12438
        const colorizer = getColorizer(chart);
12458
        const colorizer = getColorizer(chart);
12439
        datasets.forEach(colorizer);
12459
        datasets.forEach(colorizer);
12440
    }
12460
    }
Línea 13973... Línea 13993...
13973
                xSet.add(pos.x);
13993
                xSet.add(pos.x);
13974
                y += pos.y;
13994
                y += pos.y;
13975
                ++count;
13995
                ++count;
13976
            }
13996
            }
13977
        }
13997
        }
-
 
13998
        if (count === 0 || xSet.size === 0) {
-
 
13999
            return false;
-
 
14000
        }
13978
        const xAverage = [
14001
        const xAverage = [
13979
            ...xSet
14002
            ...xSet
13980
        ].reduce((a, b)=>a + b) / xSet.size;
14003
        ].reduce((a, b)=>a + b) / xSet.size;
13981
        return {
14004
        return {
13982
            x: xAverage,
14005
            x: xAverage,