robrados
robrados

Reputation: 144

Office Scripts Excel - Set Transparency for bubble chart markers

I am creating a bubble chart in the online Version of MS Excel with the Automate -> Code Editor Typescript language. I am trying to set the transparency for the markers in a bubble chart but I cannot figure it out and I couldn't find any info in the Office Scripts doc. In the following code I am looping through some info / colors / dataranges in the Worksheet and I am creating data series for the bubble chart dynamically.

for (let i = 0; i < categories_count; i++) {

var row = 13;
var column = 7;

var series_name = sheet.getCell(row + i, column).getValue();
var series_range_x = sheet.getCell(row + i, column + 1).getValue();
var series_range_y = sheet.getCell(row + i, column + 2).getValue();
var series_range_z = sheet.getCell(row + i, column + 3).getValue();
var series_color = sheet.getCell(row + i, column + 4).
getFormat().getFill().getColor();

var new_series = chart.addChartSeries(series_name);
new_series.setXAxisValues(sheet.getRange(series_range_x));
new_series.setValues(sheet.getRange(series_range_y));
new_series.setBubbleSizes(sheet.getRange(series_range_z));
new_series.getFormat().getFill().setSolidColor(series_color);

}

All the methods don't seem to have a transparency attribute which I could use. It is also strange, that I cannot set the transparency manually in the online Excel version.

Upvotes: 1

Views: 338

Answers (2)

user16187680
user16187680

Reputation: 61

You could set the Bubble chart to a certain style.

function main(workbook: ExcelScript.Workbook) {
  let sheet = workbook.getWorksheet("Sheet1");
  let newChart = sheet.addChart(ExcelScript.ChartType.bubble, sheet.getRange("B1:D6"))
  let chartStyle = newChart.getFormat().setColorScheme(25);
}

enter image description here

Setting the color scheme to 25 will give you MonochromaticPalette12 (see here).

This will give you a transparent-looking light blue for the Bubbles.

enter image description here

Upvotes: 2

wandyezj
wandyezj

Reputation: 157

Excel Online (Excel on the Web) supports a subset of features currently available in Excel Desktop.

Office Script only supports APIs that can be used in Excel Online.

If you are unable to do something (like set the transparency of a chart) in the UI in Excel Online, it's unlikely this can be done though an Office Script API.

If this feature is important for your scenario please send feedback: Automate Tab -> Code Editor -> ... -> Send Feedback

Upvotes: 0

Related Questions