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/09/20 06:59:24 UTC

[GitHub] [echarts] Ovilia commented on a diff in pull request #17579: Feat/box plot labels

Ovilia commented on code in PR #17579:
URL: https://github.com/apache/echarts/pull/17579#discussion_r974948463


##########
src/chart/boxplot/BoxplotView.ts:
##########
@@ -180,17 +183,76 @@ function updateNormalBoxData(
 
     el.useStyle(data.getItemVisual(dataIndex, 'style'));
     el.style.strokeNoScale = true;
-
     el.z2 = 100;
 
     const itemModel = data.getItemModel<BoxplotDataItemOption>(dataIndex);
     const emphasisModel = itemModel.getModel('emphasis');
 
+    if (seriesModel.option.label.show) {

Review Comment:
   We don't access the attributes using `seriesModel.option`. Please use `const labelModel = seriesModel.get('label'); const show = labelModel.get('show');` instead.
   
   Please also change `seriesModel.option` in other places.



##########
src/chart/boxplot/BoxplotView.ts:
##########
@@ -180,17 +183,76 @@ function updateNormalBoxData(
 
     el.useStyle(data.getItemVisual(dataIndex, 'style'));
     el.style.strokeNoScale = true;
-
     el.z2 = 100;
 
     const itemModel = data.getItemModel<BoxplotDataItemOption>(dataIndex);
     const emphasisModel = itemModel.getModel('emphasis');
 
+    if (seriesModel.option.label.show) {
+        const formattedLabels =
+            ((seriesModel as BoxplotSeriesModel).getRawValue(dataIndex) as number[])
+            .splice(1).map((value: number) => seriesModel.option.label.formatter(value).toString());

Review Comment:
   You should probably not create a `Text` element and do all the stuffs by yourself. Instead, `setLabelStyle` should be called. See how this is done with [line series](https://github.com/apache/echarts/blob/master/src/chart/helper/Line.ts#L275-L289). But in boxplot's case, there are multiple labels so you need to figure out how this should be done, but generally speaking, `setLabelStyle` should be called most likely.



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