Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

compilation problem in Angular #28

Open
eefth opened this issue Jan 12, 2024 · 1 comment
Open

compilation problem in Angular #28

eefth opened this issue Jan 12, 2024 · 1 comment

Comments

@eefth
Copy link

eefth commented Jan 12, 2024

I used versions 5.0.0-beat and 4.0.0 respectively, it works but I am getting the following compilation error from webpackserver:
error TS2322: Type '{ legend: { display: false; }; title: { display: true; text: string; }; labels: { fontColor: string; fontStyle: string; fontSize: number; position: string; }; }' is not assignable to type '_DeepPartialObject<PluginOptionsByType<"pie">>'.
Object literal may only specify known properties, and 'labels' does not exist in type '_DeepPartialObject<PluginOptionsByType<"pie">>'.

labels: {
fontColor: '#000',
position: 'border',
}

Any ideas?

Here is my code:

import {ActiveElement,/* Chart, */ChartEvent, registerables} from 'chart.js';
import {ClosedAlertsGraphData, OpenAlertsGraphData} from './open-alerts-graph-data.model';
import {Router} from '@angular/router';
import {OpenAlertsGraphService} from "./open-alerts-graph.service";
import {GraphTypes, OpenAlerts} from '../../../main/open-alerts/open-alerts.model';
import Chart from 'chart.js/auto';
import { getChartLabelPlugin, PLUGIN_ID} from 'chart.js-plugin-labels-dv';

const canvasElmnt = this.elementRef.nativeElement.querySelector('canvas[name="openAlertsCanvas"]');
Chart.register(getChartLabelPlugin());
const router = this.router;
const closedAlertsData = data;
const product = this.product;
Chart.defaults.font.size = 12;
console.log("them 1: " + Chart.registry?.plugins.get(PLUGIN_ID));

    this.chart = new Chart(canvasElmnt, {
        type: 'pie',
        data: closedAlertsData,
        options: {
            responsive: true,
            plugins: {
                legend: {
                    display: false
                },
                title: {
                    display: true,
                    text: 'Chart.js Pie Chart',
                },
                labels: {
                    fontColor: '#000',
                    fontStyle: 'bold',
                    fontSize: 12,
                    position: 'border',
                }
            },
            onClick(event: ChartEvent, elements: ActiveElement[], chart: Chart) {
                if (elements.length > 0) {
                    const selectedDataset = closedAlertsData.datasets[elements[0].datasetIndex];
                    const activeElementIdx = elements[0].index;
                    const selectedAlertIds = selectedDataset.alertIds[activeElementIdx];
                    void router.navigate(['/alerts', product.toLowerCase(), 'list', 'Live'], {
                        queryParams: { alertsFilter: `id+in+${selectedAlertIds.join(',')}` }
                    });
                }
            }
        }
    });
@eefth
Copy link
Author

eefth commented Jan 12, 2024

My versions are:
"chart.js": "^4.1.1",
"chart.js-plugin-labels-dv": "^4.0.0",
Same also happens with 5.0.0-beta
Angular version is: 'ng-version="12.2.16"'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant