VBA Chart Coloring - ms-access

I've got a problem with coloring chosen records from chart with VBA.
I've got some code which colors every record in my chart. Here it is:
SeriesCount = MyChart.SeriesCollection.Count
For i = 1 To SeriesCount
MyChart.SeriesCollection(i).Interior.Color = RGB(255, 0, 0)
Next
What I want is to change color of chosen record, for example 20 on picture below. Thanks for help.

You can hard code it by position. Since 20 is the 5th point in the graph you can use this code:
ActiveChart.SeriesCollection(1).Points(5).Interior.color = RGB(55, 130, 150)
If you need to search for 20, it's a little more difficult.
Sub color()
Dim MyChart As Chart
Set MyChart = ActiveChart
SeriesCount = MyChart.SeriesCollection.Count
For i = 1 To SeriesCount
Set s = MyChart.SeriesCollection(i)
vals = s.XValues
For x = LBound(vals) To UBound(vals)
If vals(x) = 20 Then
s.Points(x).Interior.color = RGB(55, 130, 150)
Else
s.Points(x).Interior.color = RGB(255, 0, 0)
End If
Next x
Next
End Sub
Tested:

Related

R Leaflet - How to combine text and figure in popup?

I would like to combine text and a figure in a Leaflet Popup. I saw this on a website of Deutsche Bahn: Multi-Object-Popup
Website:
strecken.info
For me it would be sufficient to combine two of these 4 shown "windows" -> One text (paste0()) and one ggplot-figure). Is this possible in R?
Best regards and thank you very much :)
My Code so far:
ll_maps %>%
addCircles(
data = df_temp,
lng = ~x_coord,
lat = ~y_coord,
weight = 1,
radius = 1000,
popup = ~lapply(leafpop::popupGraph(pic_list_temp, width = 500, height = 500), HTML),
label = ~lapply(paste0("<br><b>Textline1</b> = ", tl1_object,
"<br><b>Textline2</b> = ", tl2_object), HTML),
popupOptions = popupOptions(maxWidth = 500),
labelOptions = labelOptions(textsize = "12px"),
opacity = 1,
fillOpacity = 0.5,
color = "red")
Now I would like to combine the label and the popup into one popup so to speak :)

How to use finished GAN model with trianed weights to create new images?

I am following Jeff Heaton's tutorial how to create a GAN with keras. Everything works fine even with my own dataset. However, I cannot figure out how to create a single new images. (Mr. Heaton creates 28 images in form of a collages!)
What I tried without success:
new_fixed_seed = np.random.normal(0, 1, (1, 100))
generated_images = generator.predict(new_fixed_seed)
im = Image.fromarray(generated_images)
Result: TypeError: Cannot handle this data type
What am I doing wrong?
Normally, for me when I calculate generated images I am using the following code for storing them locally:
# combine a squared number of images.
def combine_images(generated_images):
generated_images = np.transpose(generated_images , (0, 3, 1, 2))
num = generated_images.shape[0]
width = int(math.sqrt(num))
height = int(math.ceil(float(num)/width))
shape = generated_images.shape[2:]
image = np.zeros((3,(height+3)*shape[0], (width+3)*shape[1]),
dtype=generated_images.dtype)
for index, img in enumerate(generated_images):
new_shape = (img.shape[0], img.shape[1]+ 4, img.shape[2] + 4)
img_ = np.zeros(new_shape)
img_[:, 2: 2+img.shape[1], 2: 2+img.shape[2]] = img
i = int(index/width)
j = index % width
image[:, i*new_shape[1]: (i+1)*new_shape[1], j*new_shape[2]: (j+1)*new_shape[2]] = img_[:, :, :]
return image
# store combined images
def store_image_maps(images_db, filename):
image = combine_images(images_db)
image = image * 127.5 + 127.5
image = np.swapaxes(image, 0, 1)
image = np.swapaxes(image, 1, 2)
cv2.imwrite(filename,image)
I got it to work but I am not completely satisfied with it as I think it could be cleaner and I think there are unnecessary steps involved:
# SEED_SIZE is 100
fixed_seed = np.random.normal(0, 1, (1, SEED_SIZE))
# used 64x64 because those were my image sizes
image_array = np.full((
64,64, 3),
255, dtype=np.uint8)
generated_images = generator.predict(fixed_seed)
#if you don't use 255 here the images are black
image_array[:] = generated_images * 255
im = Image.fromarray(image_array)
im.save('/content/drive/My Drive/Dataset/test.png')

chtobj.Chart.ChartArea.Format.Fill.Visible= msoFalse getting mismatch error

I have created a object and need to set Format.Glow, Format.Fill and Format.SoftEdge.Radius etc
The code from excel uses With Selection but that's not allowed in access. I used the watch window and see the properties but can't assign anything.
enter code here
For Each chtobj In shtTemp.ChartObjects
If chtobj.Name = "Chart4" Then
Debug.Print chtobj.Name
'
chtobj.Chart.ChartArea.Format.Fill.Visible = msoTrue
chtobj.Chart.ChartArea.Format.ForeColor.RGB = RGB(0, 176, 80)
chtobj.Chart.ChartArea.Format.Transparency = 0
chtobj.Chart.ChartArea.Format.Solid
With chtobj.Chart.ChartArea.Format.Glow
.Color.RGB = RGB(255, 255, 0)
.Transparency = 0
.Radius = 10
End With
chtobj.Chart.ChartArea.Format.Line.Visible = msoFalse
chtobj.Chart.ChartArea.Format.SoftEdge.Radius = 1
End If
Next
I found the correct syntax for VBA:
chtobj.Chart.Shapes.Parent.ChartArea.Format.Fill.Visible = msoTrue

MS Access - change colors of the bar chart based on series value

I'm trying to write a code in MS Access 2013 that will change the color of the each bar in the chart based on value of the series. Data are stored in query that changes according to the set of conditions.
In the form is chain of combo boxes and listboxes witch set the conditions for query. After requery the output is a graph.
Private Sub listS_AfterUpdate()
Me.graph.Requery
Dim i
With graph
For i = 1 To .SeriesCollection.Count
If .SeriesCollection(i).Value < 0.78 Then
.SeriesCollection(i).Border.Color = RGB(255, 0, 0)
.SeriesCollection(i).Interior.Color = RGB(255, 0, 0)
Else
.SeriesCollection(i).Border.Color = RGB(0, 255, 0)
.SeriesCollection(i).Interior.Color = RGB(0, 255, 0)
End If
Next i
End With
End Sub
The problem lies in the IF statement:
If .SeriesCollection(i).Value < 0.78 Then
Error:
Object doesn't support this property or method
Can anyone help me out with this?
Thank you
I've done this in Excel, but the way I had to do it was to have multiple ranges in the bar chart, each with a different color, and then the data in each range was selected based upon its values. Maybe this would work in Access as well?

Textbox_AfterUpdate not working with another control

Why I can't change value of another control in access form in afterupdate function?
Private Sub cNPSrate_AfterUpdate() 'Form_new_opinion_in!
If Not IsNull(cNPSRate) Then
Select Case cNPSRate
Case 1 To 6
cNPSRate.BackColor = RGB(255, 0, 0) And cSegmentNPS.Text = "KRYTYK"
Case 7 To 8
cNPSRate.BackColor = RGB(255, 255, 0) And cSegmentNPS.Text = "NEUTRALNY"
Case 9 To 10
cNPSRate.BackColor = RGB(0, 255, 0) And cSegmentNPS.Text = "PROMOTOR"
End Select
Else
cNPSRate.BackColor = RGB(255, 255, 255) And cSegmentNPS.Text = Null
End If
End Sub
The code works if I remove And cSegmentNPS.Text. Can't I use another control in this function or I make some mistake?
cNPSRate and cSegmentNPS are TEXTBOXes
A text box's .Text property is only available when that text box has focus. At any other time, use its .Value property instead.
I would also put each action on its own line instead of combining them with And on one line.
So I suggest you revise your code to follow this pattern ...
cNPSRate.BackColor = RGB(255, 0, 0)
cSegmentNPS.Value = "KRYTYK"