I am writing a script for Google Slides using Apps Script (including Slides API) for auto-formatting presentations. Crucial function there is to recolor images using certain color.
function img() {
var i_id = SlidesApp.getActivePresentation().getSlides()[0].getImages() [0].getObjectId();
Logger.log(i_id);
var p_id = SlidesApp.getActivePresentation().getId();
var requests = [{
updateImageProperties:{
objectId: i_id,
imageProperties: {
recolor: {
recolorStops: [{
color: {
rgbColor: {
red: 0.4,
green: 0.9,
blue: 0.4
}
},
alpha: 1,
position: 0.5
}]
}
},
fields: "recolor.recolorStops(color.rgbColor(red,green,blue),alpha,position)"
}
}];
Slides.Presentations.batchUpdate({'requests': requests}, p_id)}
I have written the code and it doesn't trigger error, however image is left unchanged.
After batchupdate request, the image should have been recolored. Is there a problem within the code? If anybody can provide any help, I would be so grateful!
Related
First of all, Sorry for my English. English is not my first language.
I simply want to change specific text color in Google Spreadsheets.
Example
"▶Mike: Hey, How is going on?"
In this sentence, I want to change only "▶Mike:" this part.
I have no idea what's going on in Java and programming language.
But I really need this. please help.
Thank you
If you want to change the color of a cell in Google Sheets, you can use one of the two options:
1. Use Sheets API
For updating the color of the text, you will have to use the spreadsheets.batchUpdate method.
Request
POST https://sheets.googleapis.com/v4/spreadsheets/{spreadsheetId}:batchUpdate
Body
{
"requests": [{
"repeatCell": {
"cell": {
"userEnteredFormat": {
"textFormat": {
"bold": true,
"italic": true,
"foregroundColor": {
"blue": 1.0,
"green": 0.0,
"red": 0.0
}
}
}
},
"range": {
"sheetId": 0,
"startRowIndex": 0,
"endRowIndex": 1
},
"fields": "userEnteredFormat(textFormat)"
}
}]
}
If you want to use Java, you might benefit from taking a look at this snippet from here and adapt it according to your task.
However, this option does not offer you the possibility of changing only a part of the text from the cell. For this, you should try using Apps Script.
2. Use Apps Script
Since you want to change a particular number of characters from the cell, you can use the below script
function changeColor() {
var sheet = SpreadsheetApp.getActiveSheet();
var range = sheet.getRange("A1:A2");
var redColor = SpreadsheetApp.newTextStyle()
.setForegroundColor("#ff0000")
.build();
var purpleColor = SpreadsheetApp.newTextStyle()
.setForegroundColor("#871f78")
.build();
var richTextA1 = SpreadsheetApp.newRichTextValue()
.setText("▶Mike: Hey, How is going on?")
.setTextStyle(0, 6, redColor)
.setTextStyle(7, 28, purpleColor)
.build();
var richTextA2 = SpreadsheetApp.newRichTextValue()
.setText("red words, purple words")
.setTextStyle(0, 10, redColor)
.setTextStyle(11, 23, purpleColor)
.build();
range.setRichTextValues([
[richTextA1],
[richTextA2]
]);
}
The above script creates two text styles and later applies them depending on the startOffset and the endOffset parameters which essentially represent which characters will have one of the two text styles.
After executing the above script, this is how the cells will look like:
Reference
Sheets API V4 Method: spreadsheets.batchUpdate;
Apps Script Range Class - setRichTextValues(values).
This is the link to the fiddle
https://jsfiddle.net/gh/get/library/pure/highcharts/highcharts/tree/master/samples/highcharts/plotoptions/box-plot-styling/
Below are the plotOptions.
plotOptions: {
boxplot: {
boxDashStyle: 'Dash',
fillColor: '#F0F0E0',
lineWidth: 2,
medianColor: '#0C5DA5',
medianDashStyle: 'ShortDot',
medianWidth: 3,
stemColor: '#A63400',
stemDashStyle: 'dot',
stemWidth: 1,
whiskerColor: '#3D9200',
whiskerLength: '20%',
whiskerWidth: 3
}
}
This boxplot shows high and low values in green color. In my case I need to change the high value(Q1) color in red and low value color in green.
How can I do this.?
Thank you
Currently it's not possible in Highcharts by default - related github issue: https://github.com/highcharts/highcharts/issues/6796
Currently each box is a single SVG shape and a border is applied by
stroke parameter which cannot be "separated" for smaller edges. As a
result, you can apply only single color.
Your goal requires a rebuild core of boxplot, so we cannot threat it as a bug, but feature request.
As a workaround you can render custom paths to cover one of the existing whiskers, for example:
events: {
render: function() {
var series = this.series[0],
attr,
paths;
series.points.forEach(function(point) {
paths = point.whiskers.d.split('M');
attr = {
d: 'M' + paths[1],
'stroke-width': 2,
stroke: 'red'
};
if (point.customHigh) {
point.customHigh.attr(attr);
} else {
point.customHigh = this.renderer
.path()
.attr(attr)
.add(series.group);
}
}, this);
}
}
Live demo: https://jsfiddle.net/BlackLabel/vcefbk46/
API Reference: https://api.highcharts.com/class-reference/Highcharts.SVGRenderer#path
I am trying to create a chart somehow similar to expertoptions' by using Highcharts, however I can't find solution to adding a custom marker to the line, I have tried doing something like:
var myCircle = myChart.renderer.circle(x,y,20).attr({
fill: '#d3d7de'
}).add(circlePointGroup);
var circlePointGroup = myChart.xAxis[0].renderer.g().attr({
translateX: 2000,
translateY: 2000
}).add();
but ended up being a floating static shape, I have here the fiddle, Any help would be appreciated. I have hard time reading their documentation :/
I think that a better approach might be adding this point as a scatter series - that keeps the point in the move while adding new points to the main series. Using renderer.circle renders circle in a static position.
Demo: https://jsfiddle.net/BlackLabel/Lpfj4stx/
var betWindowInterval = setInterval(function() {
myChart.xAxis[0].removePlotLine('markerLineX');
myChart.yAxis[0].removePlotLine('markerLineY');
myChart.series.forEach(s => {
if (s.options.id === 'customPoint') {
s.remove();
}
})
clearInterval(betWindowInterval)
}, 2000);
myChart.addSeries({
type: 'scatter',
data: [{x: lastPointY.x, y: lastPointY.y}],
id: 'customPoint',
marker: {
fillColor: 'red',
radius: 5,
symbol: 'circle'
}
})
API: https://api.highcharts.com/class-reference/Highcharts.Chart#addSeries
When I set this:
series: {
fillOpacity: 0.5,
fillColor:'#fff000'
}
highcharts will ignore opacity, if I take away fillcolor, the opacity works. However, I was asked to set fillcolour to be different.
http://jsfiddle.net/ywL646r8/1/. Can someone help?
Many Thanks
You can set the fill color with a rgba value
plotOptions: {
area: {
color: '#ff0000',
},
series: {
fillColor:'rgba(255,240,0,.5)'
}
http://jsfiddle.net/ywL646r8/2/
I'm drawing a polygon with OpenLayers on my OSM map.
After all neccessary things i'm executing these lines:
polygonFeature = new OpenLayers.Feature.Vector(
new OpenLayers.Geometry.Polygon([linear_ring]), null, style_green);
where style_green is
var style_green =
{
strokeColor: "#000000",
strokeOpacity: 0.3,
strokeWidth: 1,
fillColor: "#00FF00",
fillOpacity: 0.3,
};
but for some reason strokeOpacity and fillOpacity don't work, showing me solid polygon:
However, html properties of path, that's created by the openlayers code, looks legit:
How can I fix this thing?
Thank you!