OfficeDev / office-js

A repo and NPM package for Office.js, corresponding to a copy of what gets published to the official "evergreen" Office.js CDN, at https://appsforoffice.microsoft.com/lib/1/hosted/office.js.
https://learn.microsoft.com/javascript/api/overview
Other
670 stars 95 forks source link

markerBackgroundColor/markerForegroundColor properties in Excel Chart Series return an incorrect value and lack support for a ‘No Fill’/'No Border' option. #4890

Open alexuaua opened 6 days ago

alexuaua commented 6 days ago

I have reported several issues with the charts API, and I am pleased to note that they have been resolved. However, it looks like one particular bug slipped through the gaps.

The API for customizing series markers in Excel charts includes the ability to adjust the marker’s fill color (markerBackgroundColor) and border color (markerForegroundColor). However, there is currently no way to set these colors to transparent, equivalent to the “No Fill” and “No Border” options available in the UI. Unlike VSTO/VBA, where we could assign the msoFalse value, it would be logical to allow the use of the undefined value (similar to other properties) or an empty string for a transparent color.

Additionally, when reading a property, it returns #FEFFFF for no fill/no border values.

Your Environment

Expected behavior

  1. The markerBackgroundColor and markerForegroundColor properties should allow programmatic use of all possible color values (matching VSTO/VBA), including transparent (No Fill/No Border).
  2. Reading a property and writing it back should preserve the original value without any changes.

Current behavior

  1. No way to set No Fill and No Border values (transparent color).
  2. Reading a property and writing it back changes the value to #FEFFFF.

Steps to reproduce

Use this gist to run the demo in Script Lab: https://gist.github.com/alexuaua/17a95c5dd6b530d7b975aaebf4bfade6

  1. Click Load From Base64.

  2. Click Get Markers Fill Color. The console displays:

    markerBackgroundColor #FEFFFF (type: string)
  3. Click Read And Reapply Markers Color. Although we assigned a color to the value returned by the API, this action resets it to white (specifically #FEFFFF):

series.markerBackgroundColor = colorValueFunc(series.markerBackgroundColor)

  1. The demo is for markerBackgroundColor, but exactly the same issue occurs with markerForegroundColor.

5./P.S. To ensure there were no undocumented implementations similar to VSTO, I tried assigning undefined to the property as well as an empty string. One can test this by removing the worksheet with the chart (Remove button at the top), adding it once again Load From Base64 and clicking a **Set Marker Color To Empty/Undefined*** button.

Link to live example(s)

See Steps to reproduce

Provide additional details

When you put this issue to a tracker, please include all platforms including iPad, as it used to have fixes applied with a lag.

Context

One cannot use some series markers’ color values. Reading and writing a property breaks the value. API for these properties does not match VSTO/VBA.

shanshanzheng-dev commented 6 days ago

Hi @alexuaua Thanks for reaching us, we'll take a look and report back if we have a suggestion for you.