mirror of
https://github.com/Gnucash/gnucash.git
synced 2025-02-25 18:55:30 -06:00
[chartjs] upgrade chartjs to 2.9.4
fixes CVE-2020-7746
This commit is contained in:
parent
e57194379e
commit
d2a4aef3bb
6712
borrowed/chartjs/Chart.bundle.js
Normal file → Executable file
6712
borrowed/chartjs/Chart.bundle.js
Normal file → Executable file
File diff suppressed because it is too large
Load Diff
6
borrowed/chartjs/Chart.bundle.min.js
vendored
Normal file → Executable file
6
borrowed/chartjs/Chart.bundle.min.js
vendored
Normal file → Executable file
File diff suppressed because one or more lines are too long
0
borrowed/chartjs/Chart.css
Normal file → Executable file
0
borrowed/chartjs/Chart.css
Normal file → Executable file
6700
borrowed/chartjs/Chart.js
vendored
Normal file → Executable file
6700
borrowed/chartjs/Chart.js
vendored
Normal file → Executable file
File diff suppressed because it is too large
Load Diff
0
borrowed/chartjs/Chart.min.css
vendored
Normal file → Executable file
0
borrowed/chartjs/Chart.min.css
vendored
Normal file → Executable file
6
borrowed/chartjs/Chart.min.js
vendored
Normal file → Executable file
6
borrowed/chartjs/Chart.min.js
vendored
Normal file → Executable file
File diff suppressed because one or more lines are too long
0
borrowed/chartjs/LICENSE.md
Normal file → Executable file
0
borrowed/chartjs/LICENSE.md
Normal file → Executable file
32
borrowed/chartjs/README.md
Executable file
32
borrowed/chartjs/README.md
Executable file
@ -0,0 +1,32 @@
|
|||||||
|
<p align="center">
|
||||||
|
<img src="https://www.chartjs.org/media/logo-title.svg"><br/>
|
||||||
|
Simple yet flexible JavaScript charting for designers & developers
|
||||||
|
</p>
|
||||||
|
|
||||||
|
<p align="center">
|
||||||
|
<a href="https://www.chartjs.org/docs/latest/getting-started/installation.html"><img src="https://img.shields.io/github/release/chartjs/Chart.js.svg?style=flat-square&maxAge=600" alt="Downloads"></a>
|
||||||
|
<a href="https://travis-ci.org/chartjs/Chart.js"><img src="https://img.shields.io/travis/chartjs/Chart.js.svg?style=flat-square&maxAge=600" alt="Builds"></a>
|
||||||
|
<a href="https://coveralls.io/github/chartjs/Chart.js?branch=master"><img src="https://img.shields.io/coveralls/chartjs/Chart.js.svg?style=flat-square&maxAge=600" alt="Coverage"></a>
|
||||||
|
<a href="https://github.com/chartjs/awesome"><img src="https://awesome.re/badge-flat2.svg" alt="Awesome"></a>
|
||||||
|
<a href="https://chartjs-slack.herokuapp.com/"><img src="https://img.shields.io/badge/slack-chartjs-blue.svg?style=flat-square&maxAge=3600" alt="Slack"></a>
|
||||||
|
</p>
|
||||||
|
|
||||||
|
## Documentation
|
||||||
|
|
||||||
|
- [Introduction](https://www.chartjs.org/docs/latest/)
|
||||||
|
- [Getting Started](https://www.chartjs.org/docs/latest/getting-started/)
|
||||||
|
- [General](https://www.chartjs.org/docs/latest/general/)
|
||||||
|
- [Configuration](https://www.chartjs.org/docs/latest/configuration/)
|
||||||
|
- [Charts](https://www.chartjs.org/docs/latest/charts/)
|
||||||
|
- [Axes](https://www.chartjs.org/docs/latest/axes/)
|
||||||
|
- [Developers](https://www.chartjs.org/docs/latest/developers/)
|
||||||
|
- [Popular Extensions](https://github.com/chartjs/awesome)
|
||||||
|
- [Samples](https://www.chartjs.org/samples/)
|
||||||
|
|
||||||
|
## Contributing
|
||||||
|
|
||||||
|
Instructions on building and testing Chart.js can be found in [the documentation](https://github.com/chartjs/Chart.js/blob/master/docs/developers/contributing.md#building-and-testing). Before submitting an issue or a pull request, please take a moment to look over the [contributing guidelines](https://github.com/chartjs/Chart.js/blob/master/docs/developers/contributing.md) first. For support, please post questions on [Stack Overflow](https://stackoverflow.com/questions/tagged/chartjs) with the `chartjs` tag.
|
||||||
|
|
||||||
|
## License
|
||||||
|
|
||||||
|
Chart.js is available under the [MIT license](https://opensource.org/licenses/MIT).
|
@ -17,6 +17,7 @@
|
|||||||
|
|
||||||
<body>
|
<body>
|
||||||
<div style="width:1000px">
|
<div style="width:1000px">
|
||||||
|
<p>This example demonstrates a time series scale by drawing a financial line chart using just the core library. For more specific functionality for financial charts, please see <a href="https://github.com/chartjs/chartjs-chart-financial">chartjs-chart-financial</a></p>
|
||||||
<canvas id="chart1"></canvas>
|
<canvas id="chart1"></canvas>
|
||||||
</div>
|
</div>
|
||||||
<br>
|
<br>
|
||||||
@ -26,8 +27,38 @@
|
|||||||
<option value="line">Line</option>
|
<option value="line">Line</option>
|
||||||
<option value="bar">Bar</option>
|
<option value="bar">Bar</option>
|
||||||
</select>
|
</select>
|
||||||
|
<select id="unit">
|
||||||
|
<option value="second">Second</option>
|
||||||
|
<option value="minute">Minute</option>
|
||||||
|
<option value="hour">Hour</option>
|
||||||
|
<option value="day" selected>Day</option>
|
||||||
|
<option value="month">Month</option>
|
||||||
|
<option value="year">Year</option>
|
||||||
|
</select>
|
||||||
<button id="update">update</button>
|
<button id="update">update</button>
|
||||||
<script>
|
<script>
|
||||||
|
function generateData() {
|
||||||
|
var unit = document.getElementById('unit').value;
|
||||||
|
|
||||||
|
function unitLessThanDay() {
|
||||||
|
return unit === 'second' || unit === 'minute' || unit === 'hour';
|
||||||
|
}
|
||||||
|
|
||||||
|
function beforeNineThirty(date) {
|
||||||
|
return date.hour() < 9 || (date.hour() === 9 && date.minute() < 30);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Returns true if outside 9:30am-4pm on a weekday
|
||||||
|
function outsideMarketHours(date) {
|
||||||
|
if (date.isoWeekday() > 5) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
if (unitLessThanDay() && (beforeNineThirty(date) || date.hour() > 16)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
function randomNumber(min, max) {
|
function randomNumber(min, max) {
|
||||||
return Math.random() * (max - min) + min;
|
return Math.random() * (max - min) + min;
|
||||||
}
|
}
|
||||||
@ -41,14 +72,23 @@
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
var dateFormat = 'MMMM DD YYYY';
|
var date = moment('Jan 01 1990', 'MMM DD YYYY');
|
||||||
var date = moment('April 01 2017', dateFormat);
|
var now = moment();
|
||||||
var data = [randomBar(date, 30)];
|
var data = [];
|
||||||
while (data.length < 60) {
|
var lessThanDay = unitLessThanDay();
|
||||||
date = date.clone().add(1, 'd');
|
for (; data.length < 600 && date.isBefore(now); date = date.clone().add(1, unit).startOf(unit)) {
|
||||||
if (date.isoWeekday() <= 5) {
|
if (outsideMarketHours(date)) {
|
||||||
data.push(randomBar(date, data[data.length - 1].y));
|
if (!lessThanDay || !beforeNineThirty(date)) {
|
||||||
|
date = date.clone().add(date.isoWeekday() >= 5 ? 8 - date.isoWeekday() : 1, 'day');
|
||||||
}
|
}
|
||||||
|
if (lessThanDay) {
|
||||||
|
date = date.hour(9).minute(30).second(0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
data.push(randomBar(date, data.length > 0 ? data[data.length - 1].y : 30));
|
||||||
|
}
|
||||||
|
|
||||||
|
return data;
|
||||||
}
|
}
|
||||||
|
|
||||||
var ctx = document.getElementById('chart1').getContext('2d');
|
var ctx = document.getElementById('chart1').getContext('2d');
|
||||||
@ -57,13 +97,12 @@
|
|||||||
|
|
||||||
var color = Chart.helpers.color;
|
var color = Chart.helpers.color;
|
||||||
var cfg = {
|
var cfg = {
|
||||||
type: 'bar',
|
|
||||||
data: {
|
data: {
|
||||||
datasets: [{
|
datasets: [{
|
||||||
label: 'CHRT - Chart.js Corporation',
|
label: 'CHRT - Chart.js Corporation',
|
||||||
backgroundColor: color(window.chartColors.red).alpha(0.5).rgbString(),
|
backgroundColor: color(window.chartColors.red).alpha(0.5).rgbString(),
|
||||||
borderColor: window.chartColors.red,
|
borderColor: window.chartColors.red,
|
||||||
data: data,
|
data: generateData(),
|
||||||
type: 'line',
|
type: 'line',
|
||||||
pointRadius: 0,
|
pointRadius: 0,
|
||||||
fill: false,
|
fill: false,
|
||||||
@ -72,16 +111,56 @@
|
|||||||
}]
|
}]
|
||||||
},
|
},
|
||||||
options: {
|
options: {
|
||||||
|
animation: {
|
||||||
|
duration: 0
|
||||||
|
},
|
||||||
scales: {
|
scales: {
|
||||||
xAxes: [{
|
xAxes: [{
|
||||||
type: 'time',
|
type: 'time',
|
||||||
distribution: 'series',
|
distribution: 'series',
|
||||||
|
offset: true,
|
||||||
ticks: {
|
ticks: {
|
||||||
|
major: {
|
||||||
|
enabled: true,
|
||||||
|
fontStyle: 'bold'
|
||||||
|
},
|
||||||
source: 'data',
|
source: 'data',
|
||||||
autoSkip: true
|
autoSkip: true,
|
||||||
|
autoSkipPadding: 75,
|
||||||
|
maxRotation: 0,
|
||||||
|
sampleSize: 100
|
||||||
|
},
|
||||||
|
afterBuildTicks: function(scale, ticks) {
|
||||||
|
var majorUnit = scale._majorUnit;
|
||||||
|
var firstTick = ticks[0];
|
||||||
|
var i, ilen, val, tick, currMajor, lastMajor;
|
||||||
|
|
||||||
|
val = moment(ticks[0].value);
|
||||||
|
if ((majorUnit === 'minute' && val.second() === 0)
|
||||||
|
|| (majorUnit === 'hour' && val.minute() === 0)
|
||||||
|
|| (majorUnit === 'day' && val.hour() === 9)
|
||||||
|
|| (majorUnit === 'month' && val.date() <= 3 && val.isoWeekday() === 1)
|
||||||
|
|| (majorUnit === 'year' && val.month() === 0)) {
|
||||||
|
firstTick.major = true;
|
||||||
|
} else {
|
||||||
|
firstTick.major = false;
|
||||||
|
}
|
||||||
|
lastMajor = val.get(majorUnit);
|
||||||
|
|
||||||
|
for (i = 1, ilen = ticks.length; i < ilen; i++) {
|
||||||
|
tick = ticks[i];
|
||||||
|
val = moment(tick.value);
|
||||||
|
currMajor = val.get(majorUnit);
|
||||||
|
tick.major = currMajor !== lastMajor;
|
||||||
|
lastMajor = currMajor;
|
||||||
|
}
|
||||||
|
return ticks;
|
||||||
}
|
}
|
||||||
}],
|
}],
|
||||||
yAxes: [{
|
yAxes: [{
|
||||||
|
gridLines: {
|
||||||
|
drawBorder: false
|
||||||
|
},
|
||||||
scaleLabel: {
|
scaleLabel: {
|
||||||
display: true,
|
display: true,
|
||||||
labelString: 'Closing price ($)'
|
labelString: 'Closing price ($)'
|
||||||
@ -109,7 +188,9 @@
|
|||||||
|
|
||||||
document.getElementById('update').addEventListener('click', function() {
|
document.getElementById('update').addEventListener('click', function() {
|
||||||
var type = document.getElementById('type').value;
|
var type = document.getElementById('type').value;
|
||||||
chart.config.data.datasets[0].type = type;
|
var dataset = chart.config.data.datasets[0];
|
||||||
|
dataset.type = type;
|
||||||
|
dataset.data = generateData();
|
||||||
chart.update();
|
chart.update();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -26,14 +26,17 @@
|
|||||||
|
|
||||||
utils.srand(110);
|
utils.srand(110);
|
||||||
|
|
||||||
|
function getLineColor(ctx) {
|
||||||
|
return utils.color(ctx.datasetIndex);
|
||||||
|
}
|
||||||
|
|
||||||
function alternatePointStyles(ctx) {
|
function alternatePointStyles(ctx) {
|
||||||
var index = ctx.dataIndex;
|
var index = ctx.dataIndex;
|
||||||
return index % 2 === 0 ? 'circle' : 'rect';
|
return index % 2 === 0 ? 'circle' : 'rect';
|
||||||
}
|
}
|
||||||
|
|
||||||
function makeHalfAsOpaque(ctx) {
|
function makeHalfAsOpaque(ctx) {
|
||||||
var c = ctx.dataset.backgroundColor;
|
return utils.transparentize(getLineColor(ctx));
|
||||||
return utils.transparentize(c);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function adjustRadiusBasedOnData(ctx) {
|
function adjustRadiusBasedOnData(ctx) {
|
||||||
@ -56,9 +59,7 @@
|
|||||||
var data = {
|
var data = {
|
||||||
labels: utils.months({count: DATA_COUNT}),
|
labels: utils.months({count: DATA_COUNT}),
|
||||||
datasets: [{
|
datasets: [{
|
||||||
data: generateData(),
|
data: generateData()
|
||||||
backgroundColor: '#4dc9f6',
|
|
||||||
borderColor: '#4dc9f6',
|
|
||||||
}]
|
}]
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -68,8 +69,11 @@
|
|||||||
elements: {
|
elements: {
|
||||||
line: {
|
line: {
|
||||||
fill: false,
|
fill: false,
|
||||||
|
backgroundColor: getLineColor,
|
||||||
|
borderColor: getLineColor,
|
||||||
},
|
},
|
||||||
point: {
|
point: {
|
||||||
|
backgroundColor: getLineColor,
|
||||||
hoverBackgroundColor: makeHalfAsOpaque,
|
hoverBackgroundColor: makeHalfAsOpaque,
|
||||||
radius: adjustRadiusBasedOnData,
|
radius: adjustRadiusBasedOnData,
|
||||||
pointStyle: alternatePointStyles,
|
pointStyle: alternatePointStyles,
|
||||||
@ -87,12 +91,8 @@
|
|||||||
|
|
||||||
// eslint-disable-next-line no-unused-vars
|
// eslint-disable-next-line no-unused-vars
|
||||||
function addDataset() {
|
function addDataset() {
|
||||||
var newColor = utils.color(chart.data.datasets.length);
|
|
||||||
|
|
||||||
chart.data.datasets.push({
|
chart.data.datasets.push({
|
||||||
data: generateData(),
|
data: generateData()
|
||||||
backgroundColor: newColor,
|
|
||||||
borderColor: newColor
|
|
||||||
});
|
});
|
||||||
chart.update();
|
chart.update();
|
||||||
}
|
}
|
||||||
|
@ -26,14 +26,21 @@
|
|||||||
|
|
||||||
utils.srand(110);
|
utils.srand(110);
|
||||||
|
|
||||||
|
function getLineColor(ctx) {
|
||||||
|
return utils.color(ctx.datasetIndex);
|
||||||
|
}
|
||||||
|
|
||||||
function alternatePointStyles(ctx) {
|
function alternatePointStyles(ctx) {
|
||||||
var index = ctx.dataIndex;
|
var index = ctx.dataIndex;
|
||||||
return index % 2 === 0 ? 'circle' : 'rect';
|
return index % 2 === 0 ? 'circle' : 'rect';
|
||||||
}
|
}
|
||||||
|
|
||||||
function makeHalfAsOpaque(ctx) {
|
function makeHalfAsOpaque(ctx) {
|
||||||
var c = ctx.dataset.backgroundColor;
|
return utils.transparentize(getLineColor(ctx));
|
||||||
return utils.transparentize(c);
|
}
|
||||||
|
|
||||||
|
function make20PercentOpaque(ctx) {
|
||||||
|
return utils.transparentize(getLineColor(ctx), 0.8);
|
||||||
}
|
}
|
||||||
|
|
||||||
function adjustRadiusBasedOnData(ctx) {
|
function adjustRadiusBasedOnData(ctx) {
|
||||||
@ -56,9 +63,7 @@
|
|||||||
var data = {
|
var data = {
|
||||||
labels: [['Eating', 'Dinner'], ['Drinking', 'Water'], 'Sleeping', ['Designing', 'Graphics'], 'Coding', 'Cycling', 'Running'],
|
labels: [['Eating', 'Dinner'], ['Drinking', 'Water'], 'Sleeping', ['Designing', 'Graphics'], 'Coding', 'Cycling', 'Running'],
|
||||||
datasets: [{
|
datasets: [{
|
||||||
data: generateData(),
|
data: generateData()
|
||||||
backgroundColor: Chart.helpers.color('#4dc9f6').alpha(0.2).rgbString(),
|
|
||||||
borderColor: '#4dc9f6',
|
|
||||||
}]
|
}]
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -66,7 +71,12 @@
|
|||||||
legend: false,
|
legend: false,
|
||||||
tooltips: true,
|
tooltips: true,
|
||||||
elements: {
|
elements: {
|
||||||
|
line: {
|
||||||
|
backgroundColor: make20PercentOpaque,
|
||||||
|
borderColor: getLineColor,
|
||||||
|
},
|
||||||
point: {
|
point: {
|
||||||
|
backgroundColor: getLineColor,
|
||||||
hoverBackgroundColor: makeHalfAsOpaque,
|
hoverBackgroundColor: makeHalfAsOpaque,
|
||||||
radius: adjustRadiusBasedOnData,
|
radius: adjustRadiusBasedOnData,
|
||||||
pointStyle: alternatePointStyles,
|
pointStyle: alternatePointStyles,
|
||||||
@ -84,12 +94,8 @@
|
|||||||
|
|
||||||
// eslint-disable-next-line no-unused-vars
|
// eslint-disable-next-line no-unused-vars
|
||||||
function addDataset() {
|
function addDataset() {
|
||||||
var newColor = utils.color(chart.data.datasets.length);
|
|
||||||
|
|
||||||
chart.data.datasets.push({
|
chart.data.datasets.push({
|
||||||
data: generateData(),
|
data: generateData()
|
||||||
backgroundColor: Chart.helpers.color(newColor).alpha(0.2).rgbString(),
|
|
||||||
borderColor: newColor
|
|
||||||
});
|
});
|
||||||
chart.update();
|
chart.update();
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user