-
Notifications
You must be signed in to change notification settings - Fork 19.6k
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
[Feature] Line style for varied segments and connectNulls #17138
Comments
What about api like this? This is my initial idea. @Ovilia 😊 series: [
{
data: [150, 230, 224, 218, 135, 147, 260],
type: 'line',
// itemStyle and areastyle is also like this
lineStyle:{
type: "dotted", // global style
styles:{ // part style
type:'solid',
scope:[0,1],
},
}
}
] |
sorry ,styles should be an array 😅 |
@pe-2 Thanks for your suggestion. Although we do not have something like this for other options, theoretically speeking, this could also be a solution. I would suggest comparing each of these solutions and getting to a conclusion which one is the best. The thinking behind the choice of API design is the most important thing for this task. P.S. We don't have any application on this task yet. Please make sure you submit the application on time. Thanks! |
You’re welcome, It’s my pleasure. I will submit the application after I complete it. 😁 |
If we use these two APIs for setting lineStyle for null item, how could we set lineStyle for each null item individually? |
@Ovilia I'd like to add following properties to option in LineSeries.ts#L72 for implementing the second proposal: export interface LinePieceData {
index: number
leftValue: number
rightValue: number
lineStyle: LineStyleOption
isConnectNulls: boolean
}
export interface LinePiecesOption {
indexes?: number[]
rules: (piece: LinePieceData) => boolean
lineStyle?: LineStyleOption
}
export interface LineSeriesOption {
// ...
linePieces?: LinePiecesOption[]
} The new API can be call by providing the
When using property export interface LinePieceData {
// index of the line piece
index: number
// left endpoint value of the line piece
leftValue: number
// right endpoint value of the line piece
rightValue: number
// line style will be applied to the line piece
lineStyle: LineStyleOption
// indicates if the piece is used to connect null data
isConnectNulls: boolean
} What do you think of this implement? |
@zz5840 Thanks for the update. I want to clearify that if We should better use names like
|
@Ovilia Thanks for reply. I'd rather make Line index will be different from data index only if a null data exist. So if we use line index, all index will be valid, and things like index pointing to a null data will not happen. But there still exist disadvantage in line index. For example, it's hard to control the style of data segment (eg. to set the style for all data whose x-axis data is small than a certain value) when using dynamic data and number of nulls is unknown. So which index should we provide, or should we provide both? |
If the index means the ordinal number of the lines, then you must be careful because when the data is dense enough with line series, the data item (empty circles) is not always visible. Do you wish to have or ? Also, I feel it strange to exclude null data when making this index. It would mean the nth non-null line. I'm not sure if this is helpful for developers. Can you think of an example when this way is more convenient?
This is a common situation so I think we shouldn't exclude null data in the index unless we have some solid reasons. |
I didn't mean to exclude null data, I mean this is what will happen if we use the index of the left endpoint as the index of line segment. But as you say, it's very common to set the style for all data whose x-axis data is small than a certain value, so we must accept a inconsecutive index if we use choose this solution. Also, if we choose this solution, only the following image will show the correct index. |
@zz5840 Thanks for the clarification. Just a few updates on the API design: export interface LineSeriesOption {
lineSegments?: LineSegmentsOption[],
nullItemStyle?: {...}, // item style for null data
nullLineStyle?: {...},
nullAreaStyle?: {...},
// ...
}
export interface LineSegmentsOption {
dataIndexRange: number[][]
includeEndItem: boolean = true
itemStyle?: ItemStyleOption
lineStyle?: LineStyleOption
areaStyle?: AreaStyleOption
}
|
Maybe how PlottableJs handles property updates can be of help for you to decide which API is best. For each property that you can set in PlottableJs, 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 /**
* 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: 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: export interface LineSeriesOption .... {
lineStyle: LineStyleOption | IAccessor<LineStyleOption>;
...
} Then in user-land: 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. |
there is no any styles in lineStyle , and did you submit application ? |
Will this feature be implemented in the next version? |
A workaround with renderItem - Demo Code |
I really need lineStyle!!! |
Is there a way to simply make lineStyle.color and lineStyle.type accept a function. itemStyle.color already accepts a function and can give you the ability to change color based on dataPoint and index. |
thank you, i'll give it a try |
I agree with @sgtsaughter. If lineStyle.color and lineStyle.type could accept a function that would solve the issue. When I was looking through the documentation, I saw that symbolSize accepts a function so I assumed lineStyle would too. When it didn't accept a function, I searched the issue list and ended up here. PS Really impressive project! Thanks for all of the consistent updates and documentation, I know that takes a lot of work! |
@Ovilia any updates? what the current state of this issue? |
@mountpoint I plan to make a PR for v6.0. |
What problem does this feature solve?
Current API lacks the ability to control line style for varied segments. For example, if we want to make different styles for a line series, we have to mock it using many series, which is not an elegant way to do.
What does the proposed API look like?
The new option should give the developer the control over line styles for different line segments. The API could be:
or something similar to visualMap.pieces:
or callback rules:
We should also provide a way to set the lineStyle for the lines from
connectNulls
. The API may beor
or
This issue is a task for OSPP so it will probably be fixed by a student from the program. Discussion about the design and your own requirement is always welcomed.
The text was updated successfully, but these errors were encountered: