You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@echarts.apache.org by GitBox <gi...@apache.org> on 2021/03/26 03:23:32 UTC

[GitHub] [echarts] plainheart commented on a change in pull request #14497: WIP(legend): make default legend more intuitive

plainheart commented on a change in pull request #14497:
URL: https://github.com/apache/echarts/pull/14497#discussion_r601991419



##########
File path: src/component/legend/LegendModel.ts
##########
@@ -59,7 +63,77 @@ export interface LegendSelectorButtonOption {
     title?: string
 }
 
-interface DataItem {
+export interface LegendItemStyleOption {
+    color?: ZRColor | 'inherit'
+    opacity?: number | 'inherit'
+    decal?: DecalObject | 'none' | 'inherit'
+    shadowBlur?: number | 'inherit'
+    shadowColor?: ColorString | 'inherit'
+    shadowOffsetX?: number | 'inherit'
+    shadowOffsetY?: number | 'inherit'
+    borderColor?: ZRColor | 'inherit'
+    borderWidth?: number | 'inherit' | 'auto'
+    borderType?: ZRLineType | 'inherit'
+    borderCap?: CanvasLineCap | 'inherit'
+    borderJoin?: CanvasLineJoin | 'inherit'
+    borderDashOffset?: number | 'inherit'
+    borderMiterLimit?: number | 'inherit'
+}
+
+export interface LegendLineStyleOption {
+    width?: number | 'inherit' | 'auto'
+    color?: ZRColor | 'inherit'
+    opacity?: number | 'inherit'
+    type?: ZRLineType | 'inherit'
+    cap?: CanvasLineCap | 'inherit'
+    join?: CanvasLineJoin | 'inherit'
+    dashOffset?: number | 'inherit'
+    miterLimit?: number | 'inherit'
+    shadowBlur?: number | 'inherit'
+    shadowColor?: ColorString | 'inherit'
+    shadowOffsetX?: number | 'inherit'
+    shadowOffsetY?: number | 'inherit'
+    inactiveColor?: ColorString,
+    inactiveWidth?: number
+}

Review comment:
       Most of these options are extended from `ItemStyleOption` and `LineStyleOption`, so, to keep the type definition uniform for the same options in each component and the document, I'm thinking whether it would be better if we reduce some duplicate definition work and use a type utility to extend(reuse) current existing interface and only define or extend(expand) the needed extra types for options.
   
   Just personally, `LegendItemStyleOption` and `LegendLineStyleOption` could probably be simplified like this,
   
   ```ts
   // T: the type to be extended
   // ET: extended type for keys of T
   // ST: special type for T to be extended 
   type ExtendPropertyType<T, ET, ST extends { [key in keyof T]: any }> = {
       [key in keyof T]: key extends keyof ST ? T[key] | ET | ST[key] : T[key] | ET
   };
   
   export interface LegendItemStyleOption extends ExtendPropertyType<ItemStyleOption, 'inherit', {
       borderWidth?: 'auto'
   }> {}
   
   export interface LegendLineStyleOption extends ExtendPropertyType<LineStyleOption, 'inherit', {
       width?: 'auto'
   }> {
       inactiveColor?: ColorString
       inactiveWidth?: number
   }
   ```
   
   It should be working well like before.
   




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@echarts.apache.org
For additional commands, e-mail: commits-help@echarts.apache.org