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 2022/08/31 12:23:16 UTC

[GitHub] [echarts] gwak commented on issue #17138: [Feature] Line style for varied segments and connectNulls

gwak commented on issue #17138:
URL: https://github.com/apache/echarts/issues/17138#issuecomment-1232866679

   Maybe how [PlottableJs](https://github.com/palantir/plottable) handles property updates can be of help for you to decide which API is best. For each property that you can set in [PlottableJs](https://github.com/palantir/plottable), you have the choice of either give the value statically or give an accessor function:
   
   https://github.com/palantir/plottable/blob/develop/src/core/interfaces.ts#L13-L19
   ```ts
   /**
    * Accesses a specific datum property. Users supply Accessors to their
    * plots' .x, .y, .attr, etc. functions.
    */
   export interface IAccessor<T> {
       (datum: any, index: number, dataset: Dataset): T; // Inputs should be replaced by charts specific dataset data structures
   }
   ```
   
   Then when creating a Plot in Plottable:
   ```ts
   const stackedBarPlot = new Plottable.Plots.StackedBar()
         .datasets(datasets)
         .attr('fill', (d: any, I: number, dataset: Dataset) => dataset.metadata().color);
   ```
   
   How it would look like in echarts:
   ```ts
   export interface LineSeriesOption .... {
     lineStyle: LineStyleOption | IAccessor<LineStyleOption>;
   ...
   }
   ```
   Then in user-land:
   ```ts
   const baseLineStyle = {...};
   ...
   
   lineStyle: (datum: any, index: number, dataset: Dataset) => {
     return {... baseLineStyle, dashOffset: index > 10 ? 0 : 4 };
   }
   ...
   ```
   
   That way a user of the library can very easily create its own logic, that even reusable because it's a simple function.
   


-- 
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.

To unsubscribe, e-mail: commits-unsubscribe@echarts.apache.org

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