-
Notifications
You must be signed in to change notification settings - Fork 19.8k
Open
Labels
bugenThis issue is in EnglishThis issue is in EnglishpendingWe are not sure about whether this is a bug/new feature.We are not sure about whether this is a bug/new feature.typescript
Description
Version
5.4.2
Link to Minimal Reproduction
https://stackblitz.com/edit/stackblitz-starters-v7ee5w?file=src%2Fecharts.component.ts
Steps to Reproduce
The chart is created like this using ngx-echarts:
import {
ChangeDetectionStrategy,
Component,
OnInit,
ViewEncapsulation,
} from '@angular/core';
import { NgxEchartsModule, NGX_ECHARTS_CONFIG } from 'ngx-echarts';
import { fromEvent, debounceTime } from 'rxjs';
import { EChartsOption, graphic } from 'echarts';
@Component({
standalone: true,
imports: [NgxEchartsModule],
providers: [
{
provide: NGX_ECHARTS_CONFIG,
useFactory: () => ({ echarts: () => import('echarts') }),
},
],
selector: 'app-animated-bar-chart',
template:
'<div style="height: 300px;" echarts (chartInit)="onChartInit($event)" [autoResize]="false" [options]="options"></div>',
styles: [
`app-animated-bar-chart {
display:block;
}`,
],
encapsulation: ViewEncapsulation.None,
changeDetection: ChangeDetectionStrategy.OnPush,
})
export class AnimatedBarChartComponent implements OnInit {
private data: number[] = [300, 520, 435, 530, 730, 620, 660, 860];
echartsIntance: any;
// options!: EChartsOption;
options!: EChartsOption;
//options!: any;
constructor() {
this.resize();
}
ngOnInit(): void {
this.options = {
tooltip: {
trigger: 'item',
formatter: '',
},
series: [
{
name: ' ',
clockwise: true,
type: 'pie',
radius: ['65%', '100%'],
center: ['50%', '50%'],
data: [
{
value: 500,
name: 'Solana',
label: {
position: 'center',
formatter: '',
fontSize: 22,
fontWeight: 600,
fontFamily: 'Roboto',
color: 'blue',
},
tooltip: {},
},
{
value: 500,
name: 'Tether',
},
{
value: 1000,
name: 'Golem',
},
],
},
],
};
}
resize() {
fromEvent(window, 'resize')
.pipe(debounceTime(200))
.subscribe((e) => {
console.log('RESIZE');
if (this.echartsIntance) {
this.echartsIntance.resize({
animation: {
duration: 1500,
easing: 'elasticOut',
},
});
}
});
}
onChartInit(echarts: any) {
this.echartsIntance = echarts;
}
}
Current Behavior
The EChartsOption should allow for specifying a tooltip when creating a pie chart data series. I've documented the rest in this Stackoverflow question with a runnable example.
Expected Behavior
It should compile. However this error is produced.
Error in src/echarts.component.ts (66:15)
Type '{ name: string; clockwise: true; type: "pie"; radius: string[]; center: string[]; data: ({ value: number; name: string; label: { position: "center"; formatter: string; fontSize: number; fontWeight: number; fontFamily: string; color: string; }; tooltip: {}; } | { ...; })[]; }' is not assignable to type 'SeriesOption$1'.
Types of property 'data' are incompatible.
Type '({ value: number; name: string; label: { position: "center"; formatter: string; fontSize: number; fontWeight: number; fontFamily: string; color: string; }; tooltip: {}; } | { value: number; name: string; })[]' is not assignable to type '(OptionDataValueNumeric | OptionDataValueNumeric[] | PieDataItemOption)[]'.
Type '{ value: number; name: string; label: { position: "center"; formatter: string; fontSize: number; fontWeight: number; fontFamily: string; color: string; }; tooltip: {}; } | { value: number; name: string; }' is not assignable to type 'OptionDataValueNumeric | OptionDataValueNumeric[] | PieDataItemOption'.
Type '{ value: number; name: string; label: { position: "center"; formatter: string; fontSize: number; fontWeight: number; fontFamily: string; color: string; }; tooltip: {}; }' is not assignable to type 'OptionDataValueNumeric | OptionDataValueNumeric[] | PieDataItemOption'.
Object literal may only specify known properties, and 'tooltip' does not exist in type 'OptionDataValueNumeric[] | PieDataItemOption'.
Environment
- OS:macOS Sonoma 14
- Browser: Chrome and Firefox
- Framework: AngularAny additional comments?
I was trying to create a PIE chart with a tooltip on the data series.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
bugenThis issue is in EnglishThis issue is in EnglishpendingWe are not sure about whether this is a bug/new feature.We are not sure about whether this is a bug/new feature.typescript