mirror of
https://github.com/chartjs/Chart.js.git
synced 2024-10-06 12:19:08 +02:00
Clean up a few sample issues (#8790)
This commit is contained in:
parent
98e890cc7b
commit
96dd201028
@ -237,7 +237,7 @@ It is common to want to apply a configuration setting to all created bar charts.
|
|||||||
|
|
||||||
The following shows the relationship between the bar percentage option and the category percentage option.
|
The following shows the relationship between the bar percentage option and the category percentage option.
|
||||||
|
|
||||||
```text
|
```
|
||||||
// categoryPercentage: 1.0
|
// categoryPercentage: 1.0
|
||||||
// barPercentage: 1.0
|
// barPercentage: 1.0
|
||||||
Bar: | 1.0 | 1.0 |
|
Bar: | 1.0 | 1.0 |
|
||||||
|
@ -8,6 +8,7 @@ const actions = [
|
|||||||
{
|
{
|
||||||
name: 'Mode: index',
|
name: 'Mode: index',
|
||||||
handler(chart) {
|
handler(chart) {
|
||||||
|
chart.options.interaction.axis = 'xy';
|
||||||
chart.options.interaction.mode = 'index';
|
chart.options.interaction.mode = 'index';
|
||||||
chart.update();
|
chart.update();
|
||||||
}
|
}
|
||||||
@ -15,6 +16,7 @@ const actions = [
|
|||||||
{
|
{
|
||||||
name: 'Mode: dataset',
|
name: 'Mode: dataset',
|
||||||
handler(chart) {
|
handler(chart) {
|
||||||
|
chart.options.interaction.axis = 'xy';
|
||||||
chart.options.interaction.mode = 'dataset';
|
chart.options.interaction.mode = 'dataset';
|
||||||
chart.update();
|
chart.update();
|
||||||
}
|
}
|
||||||
@ -22,6 +24,7 @@ const actions = [
|
|||||||
{
|
{
|
||||||
name: 'Mode: point',
|
name: 'Mode: point',
|
||||||
handler(chart) {
|
handler(chart) {
|
||||||
|
chart.options.interaction.axis = 'xy';
|
||||||
chart.options.interaction.mode = 'point';
|
chart.options.interaction.mode = 'point';
|
||||||
chart.update();
|
chart.update();
|
||||||
}
|
}
|
||||||
@ -29,6 +32,7 @@ const actions = [
|
|||||||
{
|
{
|
||||||
name: 'Mode: nearest',
|
name: 'Mode: nearest',
|
||||||
handler(chart) {
|
handler(chart) {
|
||||||
|
chart.options.interaction.axis = 'xy';
|
||||||
chart.options.interaction.mode = 'nearest';
|
chart.options.interaction.mode = 'nearest';
|
||||||
chart.update();
|
chart.update();
|
||||||
}
|
}
|
||||||
|
@ -57,6 +57,12 @@ const data = {
|
|||||||
// Create a custom tooltip positioner to put at the bottom of the chart area
|
// Create a custom tooltip positioner to put at the bottom of the chart area
|
||||||
components.Tooltip.positioners.bottom = function(items) {
|
components.Tooltip.positioners.bottom = function(items) {
|
||||||
const pos = components.Tooltip.positioners.average(items);
|
const pos = components.Tooltip.positioners.average(items);
|
||||||
|
|
||||||
|
// Happens when nothing is found
|
||||||
|
if (pos === false) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
const chart = this._chart;
|
const chart = this._chart;
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
Loading…
Reference in New Issue
Block a user