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

feat(type): export EChartsInitOpts and some Payload types for echarts/core #19103

Merged
merged 2 commits into from
Sep 12, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
feat: add missing types
  • Loading branch information
Dale Nguyen committed Sep 11, 2023
commit 621e137c2a9c67a22bd982ea74612f76268d609d
2 changes: 1 addition & 1 deletion src/core/echarts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -318,7 +318,7 @@ type ECEventDefinition = {
// TODO: Use ECActionEvent
[key: string]: (...args: unknown[]) => void | boolean
};
type EChartsInitOpts = {
export type EChartsInitOpts = {
locale?: string | LocaleOption,
renderer?: RendererType,
devicePixelRatio?: number,
Expand Down
44 changes: 26 additions & 18 deletions src/export/core.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,16 +25,24 @@ import { use } from '../extension';

// Import label layout by default.
// TODO will be treeshaked.
import {installLabelLayout} from '../label/installLabelLayout';
import { installLabelLayout } from '../label/installLabelLayout';
use(installLabelLayout);


// Export necessary types
export {ZRColor as Color, Payload, ECElementEvent} from '../util/types';
export {LinearGradientObject} from 'zrender/src/graphic/LinearGradient';
export {RadialGradientObject} from 'zrender/src/graphic/RadialGradient';
export {PatternObject, ImagePatternObject, SVGPatternObject} from 'zrender/src/graphic/Pattern';
export {ElementEvent} from 'zrender/src/Element';
export {
ZRColor as Color,
Payload,
ECElementEvent,
HighlightPayload,
DownplayPayload,
SelectChangedPayload
} from '../util/types';
export { LinearGradientObject } from 'zrender/src/graphic/LinearGradient';
export { RadialGradientObject } from 'zrender/src/graphic/RadialGradient';
export { PatternObject, ImagePatternObject, SVGPatternObject } from 'zrender/src/graphic/Pattern';
export { ElementEvent } from 'zrender/src/Element';
export * from './option';
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure about this line. @pissang Do we miss an echarts/option entry or echarts/all entry? It seems we can only import them from echarts/types/dist folder now. Please take a look.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@plainheart, you're right. I was looking for the incorrect type name for the option.

For example,

interface EChartsOption extends ECBasicOption {
    dataset?: DatasetOption | DatasetOption[];
    aria?: AriaOption;
    title?: TitleOption | TitleOption[];
    grid?: GridOption | GridOption[];
    radar?: RadarOption | RadarOption[];
    polar?: PolarOption | PolarOption[];
    geo?: GeoOption | GeoOption[];
    angleAxis?: AngleAxisOption | AngleAxisOption[];
    radiusAxis?: RadiusAxisOption | RadiusAxisOption[];
    xAxis?: XAXisOption | XAXisOption[];
    yAxis?: YAXisOption | YAXisOption[];
    singleAxis?: SingleAxisOption | SingleAxisOption[];
    parallel?: ParallelCoordinateSystemOption | ParallelCoordinateSystemOption[];
    parallelAxis?: ParallelAxisOption | ParallelAxisOption[];
    calendar?: CalendarOption | CalendarOption[];
    toolbox?: ToolboxComponentOption | ToolboxComponentOption[];
    tooltip?: TooltipOption | TooltipOption[];
    axisPointer?: AxisPointerOption | AxisPointerOption[];
    brush?: BrushOption | BrushOption[];
    timeline?: TimelineOption | SliderTimelineOption;
    legend?: LegendComponentOption | (LegendComponentOption)[];
    dataZoom?: DataZoomComponentOption | (DataZoomComponentOption)[];
    visualMap?: VisualMapComponentOption | (VisualMapComponentOption)[];
    graphic?: GraphicComponentLooseOption | GraphicComponentLooseOption[];
    series?: SeriesOption$1 | SeriesOption$1[];
    options?: EChartsOption[];
    baseOption?: EChartsOption;
}

I was looking to import TooltipOption type. However, it's already exported as TooltipComponentOption, which is a little confusing when looking at the type.

I will revert this change.


// ComposeOption
import type { ComponentOption, ECBasicOption as EChartsCoreOption } from '../util/types';
Expand All @@ -45,9 +53,9 @@ import type { AngleAxisOption, RadiusAxisOption } from '../coord/polar/AxisModel
import type { ParallelAxisOption } from '../coord/parallel/AxisModel';


export {EChartsType as ECharts} from '../core/echarts';
export { EChartsType as ECharts } from '../core/echarts';

export {EChartsCoreOption};
export { EChartsCoreOption };

// type SeriesSubComponentsTypes = 'markPoint' | 'markLine' | 'markArea' | 'tooltip';
// type InjectSeriesSubComponents<OptionUnion extends ComponentOption, Injected> =
Expand Down Expand Up @@ -92,16 +100,16 @@ type ComposeUnitOption<OptionUnion extends ComponentOption> =
Omit<EChartsCoreOption, 'baseOption' | 'options'> & {
[key in GetMainType<OptionUnion>]?: Arrayable<
ExtractComponentOption<OptionUnion, key>
// TODO: It will make error log too complex.
// So this more strict type checking will not be used currently to make sure the error msg is friendly.
//
// Inject markPoint, markLine, markArea, tooltip in series.
// ExtractComponentOption<
// InjectSeriesSubComponents<
// OptionUnion, GetSeriesInjectedSubOption<GetMainType<OptionUnion>, OptionUnion>
// >,
// key
// >
// TODO: It will make error log too complex.
// So this more strict type checking will not be used currently to make sure the error msg is friendly.
//
// Inject markPoint, markLine, markArea, tooltip in series.
// ExtractComponentOption<
// InjectSeriesSubComponents<
// OptionUnion, GetSeriesInjectedSubOption<GetMainType<OptionUnion>, OptionUnion>
// >,
// key
// >
>
} & GetDependencies<GetMainType<OptionUnion>>;

Expand Down