At the beginning of a study its overlay state is defined:
study("My title", overlay=true)
Is it possible to query/use that state inside the code?
I thought of building a more versatile indicator
and decide wether or not to plot something:
plotshape((overlay == true ? my_series1 : na), title="my shape", style=style=shape.diamond,...)
plot((overlay == false ? my_series2 : na),title="my line", style=plot.style_line,...)
The second plot could be for example an oscillating line, which is better plotted on a separate chart window.
No, that's not possible.
However, you can use a bool input to decide whether to plot something or not.
study("My Script", overlay=false)
isPlotClose = input(title="Plot close?", type=input.bool, defval=true)
plot(series=isPlotClose ? close : na)
Related
Using the answer provided by aka863 here: How to split merged Excel cells with Python?
I can unmerge, fill values and copy the styling. My questions is how to make the value assigning/filling process configurable.
I want the user to be able to choose whether the values will be filled vertically/horizontally.
I have tried changing the last loop where we assign the top_left_cell_values to unmerged cells. However I couldn't find a way to make it horizontal/vertical configurable. (I'm planning to use radio buttons and tkinter for this)
Its certainly possible to have the code de-merge cells and fill cells in whichever direction, vertically or horizontally regardless of which way the merge was originally. Or not fill at all, so only the top left cell retains the 'value' of the previously merged cells, which is default on unmerge.
Changing the direction of the fill requires some change and re-calculation on the max row and column values in the iter_rows loop, but is simple enough.
However it seems in your last comment you just want to give the user the option to fill or not fill on horizontal merges. In that case you just need to ask the question, and then run the iter_rows loop only if the response is yes.
The code sample below is based on the answer referenced question.
I'm assuming only single line horizontal merges since you dont mention what if anything should be done with vertical merges in the comment.
The code does initially check and indicate the merge direction either vertically or horizontally so it can be included take some action if a merge is vertical.
On code run after displaying the range and direction of the merge, the question is asked to fill, yes or no. If yes the cells are de-merged and all cells filled with the top left cell value using the iter_rows loop. If answer no then the cells are just de-merged.
from openpyxl import load_workbook
from openpyxl.utils.cell import range_boundaries
wb = load_workbook(filename='foo.xlsx')
st = wb['Sheet1']
mcr_coord_list = [mcr.coord for mcr in st.merged_cells.ranges]
direction_dict = {'v': 'vertical', 'h': 'horizontal'}
for mcr in mcr_coord_list:
print('---------------------------------------------------\n')
merge_direction = ''
min_col, min_row, max_col, max_row = range_boundaries(mcr)
top_left_cell_value = st.cell(row=min_row, column=min_col).value
if min_col == max_col:
merge_direction = 'v'
elif min_row == max_row:
merge_direction = 'h'
print(f"The cell range {mcr} is merged {direction_dict[merge_direction]}ly with the data '{top_left_cell_value}'")
while True:
demerge_fill = input('Do you want the de-merge to fill all cells(y|n)? ')
if demerge_fill.lower() in ["y", "n"]:
break
else:
print('Invalid response')
st.unmerge_cells(mcr)
if demerge_fill == 'y':
for row in st.iter_rows(min_col=min_col, min_row=min_row, max_col=max_col, max_row=max_row):
for cell in row:
cell.value = top_left_cell_value
else:
print(f"Only the top left cell {mcr.split(':')[0]} will contain the data!")
wb.save('merged_tmp.xlsx')
I've got an ECharts chart that has multiple line series and a scatter series that represents events. For the line series, we left the symbol at the default, but for the event scatter series we set the symbol to 'diamond'. These symbols show up on the chart & in the series legend as expected. However, the tooltip always shows a 10 pixel dot for the marker. The color however is picked up from the series (and even from the visualMap config!). My initial assumption had been that the symbol would also be picked up from the series. In our case we wanted to use a function for tooltip.formatter and even in that function we couldn't figure out how to access and swap in the series symbol for the marker. We ended up working around it by just custom styling our own html to plug in for the marker that matched the diamond symbol pretty well.
So the open questions are:
Is there a way to have the tooltip marker pick up the symbol from the series?
If not, is this a bug? I'm happy to put in an issue on the project but I don't want to do that until I understand a bit more.
Here's some code to illustrate what we had to do to get the diamond in there in case it helps the discussion or if others want to leverage this workaround:
formatTooltip(args){
let time = DateTime.fromISO(args[0].data[0], { zone: this.user.timeZone })
let tooltip = `<div><b>${time.toFormat(TOOLTIP_FORMAT)}</b></div>`
args.forEach(({ marker, seriesName, value }) => {
if (seriesName === 'Events'){
let myMarker = `<span style="display:inline-block;margin-right:4px;width:10px;height:10px;background:${value[4]};transform:rotate(45deg);"></span>`
tooltip += `<div>${myMarker} ${value[3] ? value[3]: ''}</div>`
} else {
value = value || [0, 0]
tooltip += `<div>${marker} ${seriesName}: ${value[1]}</div>`
}
})
return tooltip
},
For better understanding of this question, let me show a working example in TradingView webpage, on which the following chart shows the combination of Momentum (area chart) + ADX (line chart):
As you can see, there are 2 vertical values, at left side is the ADX which the scale goes usually from 0 to 60(+-), but the right side, it can grow much more.
On my attempt to achieve the same here, the momentum (area chart) has a huge range, and the adx (lineal chart) goes from 0 to 60, so when it tries to fit both values under the same scale, my blue line looks like it's almost zero, in comparison with the area chart values. (Mouse-over the blue line showing that is currently 43)
So I think you get the point, would it be possible to have 2 scales/vAxis for each series of values?
I checked documentation already but nothing here seems to refer to what I mention:
https://developers.google.com/chart/interactive/docs/gallery/combochart
And just in case you need the options provided to the chart, nothing advanced, just the basic examples:
options:{
seriesType: 'area',
series: {
0: { type: 'line', color: 'blue' }
}
};
use option --> targetAxisIndex -- in the series option...
zero is the default v-axis
targetAxisIndex: 0
to create a second v-axis, assign one of the series to index 1
series: {
1: {
targetAxisIndex: 1
}
}
Found the solution over this post in the documentation, it is conceptually known as DUAL-Y Charts
https://developers.google.com/chart/interactive/docs/gallery/columnchart#dual-y-charts
I am trying to show my picture as a negative, and I coded it, but it wont show the picture as a negative, did I do something wrong?
def negative(picButterfly2):
for px in getPixels(picButterfly1):
red=getRed(px)
green=getGreen(px)
blue=getBlue(px)
negColor=makeColor(255-red, 255-green, 255-blue)
setColor(px,negColor)
ALSO HOW DO I DRAW HORIZONTAL LINES? Thanks!
Try with correct variables names: you have picButterfly2 NOT EQUAL TO picButterfly1:
This works:
def negative(picButterfly1):
for px in getPixels(picButterfly1):
red=getRed(px)
green=getGreen(px)
blue=getBlue(px)
negColor=makeColor(255-red, 255-green, 255-blue)
setColor(px,negColor)
file = pickAFile()
picture = makePicture(file)
negative(picture)
show(picture)
Also look at:
This (for negating images).
This (for drawing lines) - or any of those.
Your variables "red", "blue", and "green" already have a function in it, change it to a single character or just a capital letter like "Red". I know this was posted in 2014 but I'll leave a comment for the future.
I have a column in SSRS report. The value is "True" or "False" or "Yes" or "No" or "1" or "0"
Instead of showing that in that column, I would like to use indicator.
I placed indicator in that column but need to set start and end property. How do I go about doing it so I can show green checkmark when it's "True", "Yes", or '1" and red otherwise?
I am trying =IFF(Fields!Column_name.Value = "True", "Red", "Green") for the Start value for Green Check mark...but obviously I am wrong...
any help?
Well maybe its just a typo in your question but a couple things stand out
the function is IIF, not IFF
The True result should come first after the condition
I've never used the indicators before, but looking briefly at them, it looks like you can define ranges that are acceptable (green), unacceptable(red), or in the middle (yellow).
Start and End should probably be numeric values, "Green" and "Red" don't seem like valid values.
Try binding the indicator value expression to something like this.
=IIF(Fields!ColumnName.Value = "True" OrElse
Fields!ColumnName.Value = "Yes" OrElse
Fields!ColumnName.Value = "1", 100, 0)
Go to the Indicators properties > Values And States and put the Check's Start & End Value to 1. And the X put it's Start & End Value to 0.
Then write your expression like this:
=iif(First(Fields!YourField.Value, "YourDataSet")=True,1,0)
That should give you a Check if checked or an X if not.