Fix/area fill and chart titles (#8113)

* fixed fill for area chart stacked and title for charts where it wasn't in plugins yet
* Chart defined in utils
* added radar skip points example in the overview to go to
This commit is contained in:
LeeLenaleee 2020-11-30 15:59:20 +01:00 committed by GitHub
parent 8220caaa43
commit c3fbe5efc3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
29 changed files with 134 additions and 75 deletions

View File

@ -42,9 +42,11 @@ function updateConfigByMutating(chart) {
function updateConfigAsNewObject(chart) { function updateConfigAsNewObject(chart) {
chart.options = { chart.options = {
responsive: true, responsive: true,
plugins: {
title: { title: {
display: true, display: true,
text: 'Chart.js' text: 'Chart.js'
}
}, },
scales: { scales: {
x: { x: {

View File

@ -33,9 +33,11 @@ const chart = new Chart(ctx, {
type: 'line', type: 'line',
// data: ... // data: ...
options: { options: {
plugins: {
title: { title: {
display: true, display: true,
text: 'Chart Title' text: 'Chart Title'
}
}, },
scales: { scales: {
x: { x: {

View File

@ -58,9 +58,11 @@
}] }]
}, },
options: { options: {
plugins: {
title: { title: {
display: true, display: true,
text: 'Chart.js Line Chart - Animation Progress Bar' text: 'Chart.js Line Chart - Animation Progress Bar'
}
}, },
animation: { animation: {
duration: 2000, duration: 2000,

View File

@ -86,10 +86,12 @@
}] }]
}, },
options: Chart.helpers.merge(options, { options: Chart.helpers.merge(options, {
plugins: {
title: { title: {
text: 'fill: ' + boundary, text: 'fill: ' + boundary,
display: true display: true
} }
},
}) })
}); });
}); });

View File

@ -44,6 +44,7 @@
randomScalingFactor(), randomScalingFactor(),
randomScalingFactor() randomScalingFactor()
], ],
fill: true
}, { }, {
label: 'My Second dataset', label: 'My Second dataset',
borderColor: window.chartColors.blue, borderColor: window.chartColors.blue,
@ -57,6 +58,7 @@
randomScalingFactor(), randomScalingFactor(),
randomScalingFactor() randomScalingFactor()
], ],
fill: true
}, { }, {
label: 'My Third dataset', label: 'My Third dataset',
borderColor: window.chartColors.green, borderColor: window.chartColors.green,
@ -70,6 +72,7 @@
randomScalingFactor(), randomScalingFactor(),
randomScalingFactor() randomScalingFactor()
], ],
fill: true
}, { }, {
label: 'My Fourth dataset', label: 'My Fourth dataset',
borderColor: window.chartColors.yellow, borderColor: window.chartColors.yellow,
@ -83,6 +86,7 @@
randomScalingFactor(), randomScalingFactor(),
randomScalingFactor() randomScalingFactor()
], ],
fill: true
}] }]
}, },
options: { options: {

View File

@ -67,7 +67,7 @@
type: 'bar', type: 'bar',
data: barChartData, data: barChartData,
options: { options: {
plugin: { plugins: {
title: { title: {
display: true, display: true,
text: 'Chart.js Bar Chart - Stacked' text: 'Chart.js Bar Chart - Stacked'

View File

@ -66,9 +66,11 @@
mode: 'index' mode: 'index'
}, },
stacked: false, stacked: false,
plugins: {
title: { title: {
display: true, display: true,
text: 'Chart.js Line Chart - Multi Axis' text: 'Chart.js Line Chart - Multi Axis'
}
}, },
scales: { scales: {
y: { y: {

View File

@ -45,11 +45,13 @@
}, },
options: { options: {
responsive: true, responsive: true,
plugins: {
title: { title: {
display: true, display: true,
text: details.label, text: details.label,
} }
} }
}
}; };
} }

View File

@ -48,7 +48,7 @@
labels: { labels: {
generateLabels: function(chart) { generateLabels: function(chart) {
// Get the default label list // Get the default label list
var original = Chart.defaults.controllers.pie.legend.labels.generateLabels; var original = Chart.defaults.controllers.pie.plugins.legend.labels.generateLabels;
var labels = original.call(this, chart); var labels = original.call(this, chart);
// Build an array of colors used in the datasets of the chart // Build an array of colors used in the datasets of the chart

View File

@ -74,9 +74,11 @@
}] }]
}, },
options: { options: {
plugins: {
title: { title: {
display: true, display: true,
text: 'Chart.js Radar Chart - Skip Points' text: 'Chart.js Radar Chart - Skip Points'
}
}, },
elements: { elements: {
line: { line: {

View File

@ -52,10 +52,12 @@
type: 'scatter', type: 'scatter',
data: scatterChartData, data: scatterChartData,
options: { options: {
plugins: {
title: { title: {
display: true, display: true,
text: 'Chart.js Scatter Chart' text: 'Chart.js Scatter Chart'
}, }
}
} }
}); });
}; };

View File

@ -92,9 +92,11 @@
intersect: true, intersect: true,
mode: 'nearest' mode: 'nearest'
}, },
plugins: {
title: { title: {
display: true, display: true,
text: 'Chart.js Scatter Chart - Multi Axis' text: 'Chart.js Scatter Chart - Multi Axis'
}
}, },
scales: { scales: {
x: { x: {

View File

@ -7,6 +7,7 @@
<link rel="stylesheet" type="text/css" href="style.css"> <link rel="stylesheet" type="text/css" href="style.css">
<link rel="icon" href="favicon.ico"> <link rel="icon" href="favicon.ico">
<script src="samples.js"></script> <script src="samples.js"></script>
<script src="../dist/chart.min.js"></script>
<script src="utils.js"></script> <script src="utils.js"></script>
<title>Chart.js samples</title> <title>Chart.js samples</title>
</head> </head>

View File

@ -91,6 +91,9 @@
}, { }, {
title: 'Radar', title: 'Radar',
path: 'charts/radar.html' path: 'charts/radar.html'
}, {
title: 'Radar skip points',
path: 'charts/radar-skip-points.html'
}, { }, {
title: 'Combo bar/line', title: 'Combo bar/line',
path: 'charts/combo-bar-line.html' path: 'charts/combo-bar-line.html'

View File

@ -61,10 +61,13 @@
data: scatterChartData, data: scatterChartData,
options: { options: {
responsive: true, responsive: true,
plugins: {
title: { title: {
display: true, display: true,
text: title text: title
}
}, },
scales: { scales: {
x: { x: {
position: xPosition, position: xPosition,

View File

@ -59,9 +59,11 @@
}, },
options: { options: {
responsive: true, responsive: true,
plugins: {
title: { title: {
display: true, display: true,
text: 'Chart.js Line Chart - X-Axis Filter' text: 'Chart.js Line Chart - X-Axis Filter'
}
}, },
scales: { scales: {
x: { x: {

View File

@ -50,9 +50,11 @@
}, },
options: { options: {
responsive: true, responsive: true,
plugins: {
title: { title: {
display: true, display: true,
text: title text: title
}
}, },
scales: { scales: {
x: { x: {

View File

@ -39,9 +39,11 @@
}, },
options: { options: {
responsive: true, responsive: true,
plugins: {
title: { title: {
display: true, display: true,
text: 'Grid Line Settings' text: 'Grid Line Settings'
}
}, },
scales: { scales: {
y: { y: {

View File

@ -39,9 +39,11 @@
}, },
options: { options: {
responsive: true, responsive: true,
plugins: {
title: { title: {
display: true, display: true,
text: 'Grid Line Settings' text: 'Grid Line Settings'
}
}, },
scales: { scales: {
y: { y: {

View File

@ -39,9 +39,11 @@
}, },
options: { options: {
responsive: true, responsive: true,
plugins: {
title: { title: {
display: true, display: true,
text: 'Min and Max Settings' text: 'Min and Max Settings'
}
}, },
scales: { scales: {
y: { y: {

View File

@ -60,9 +60,11 @@
}, },
options: { options: {
responsive: true, responsive: true,
plugins: {
title: { title: {
display: true, display: true,
text: 'Chart.js Line Chart - Logarithmic' text: 'Chart.js Line Chart - Logarithmic'
}
}, },
scales: { scales: {
x: { x: {

View File

@ -128,9 +128,11 @@
type: 'scatter', type: 'scatter',
data: scatterChartData, data: scatterChartData,
options: { options: {
plugins: {
title: { title: {
display: true, display: true,
text: 'Chart.js Scatter Chart - Logarithmic X-Axis' text: 'Chart.js Scatter Chart - Logarithmic X-Axis'
}
}, },
scales: { scales: {
x: { x: {

View File

@ -69,10 +69,12 @@
}, },
options: { options: {
responsive: true, responsive: true,
plugins: {
title: { title: {
display: true, display: true,
text: 'Chart with Multiline Labels' text: 'Chart with Multiline Labels'
}, }
}
} }
}; };

View File

@ -34,9 +34,11 @@
}, },
options: { options: {
responsive: true, responsive: true,
plugins: {
title: { title: {
display: true, display: true,
text: 'Chart with Non Numeric Y Axis' text: 'Chart with Non Numeric Y Axis'
}
}, },
scales: { scales: {
x: { x: {

View File

@ -72,8 +72,11 @@
}] }]
}, },
options: { options: {
plugins: {
title: { title: {
text: 'Chart.js Combo Time Scale' text: 'Chart.js Combo Time Scale',
display: true
}
}, },
scales: { scales: {
x: { x: {

View File

@ -79,9 +79,11 @@
options: { options: {
spanGaps: 1000 * 60 * 60 * 24 * 2, // 2 days spanGaps: 1000 * 60 * 60 * 24 * 2, // 2 days
responsive: true, responsive: true,
plugins: {
title: { title: {
display: true, display: true,
text: 'Chart.js Time - spanGaps: 172800000 (2 days in ms)' text: 'Chart.js Time - spanGaps: 172800000 (2 days in ms)'
}
}, },
scales: { scales: {
x: { x: {

View File

@ -78,9 +78,11 @@
}, },
options: { options: {
responsive: true, responsive: true,
plugins: {
title: { title: {
display: true, display: true,
text: 'Chart.js Time Point Data' text: 'Chart.js Time Point Data'
}
}, },
scales: { scales: {
x: { x: {

View File

@ -100,8 +100,11 @@
}] }]
}, },
options: { options: {
plugins: {
title: { title: {
text: 'Chart.js Time Scale' text: 'Chart.js Time Scale',
display: true
}
}, },
scales: { scales: {
x: { x: {

View File

@ -62,9 +62,11 @@
}, },
options: { options: {
responsive: true, responsive: true,
plugins: {
title: { title: {
display: true, display: true,
text: 'Chart.js Line Chart - ' + type text: 'Chart.js Line Chart - ' + type
}
}, },
scales: { scales: {
x: { x: {