Hide labels in googleVis Bubble Charts - json

I want to hide the labels. I believe it is something to do with the option bubble.textStyle and setting the color to none but I can't figure it out.
Bubble <- gvisBubbleChart(Fruits, idvar="Fruit", xvar="Sales", yvar="Expenses",
colorvar="Year", sizevar="Profit",
options=list(hAxis='{minValue:75, maxValue:125}',
width=500, height=300))
plot(Bubble)
Thanks..

The tricky thing is that it's a JSON object inside a JSON object. First you use bubble="{} to create the first JSON object and then textStyle:{} to create the next JSON object inside bubble="{}.
Here is my code and a screenshot,
# install.packages("googleVis", dependencies = TRUE)
require(googleVis)
Bubble <- gvisBubbleChart(Fruits, idvar="Fruit", xvar="Sales", yvar="Expenses",
colorvar="Year", sizevar="Profit",
options=list(hAxis='{minValue:75, maxValue:125}',
width=500, height=300),
bubble="{textStyle:{color: 'none', fontName:
<global-font-name>, fontSize:
<global-font-size>}}")
plot(Bubble)

Related

Callback for multivalue dropdown

I am pretty new to Plotly Dash and have been struggling especially with multivalue dropdown callback and would really appreciate any help. Basically I've followed a tutorial and created a pie-chart if a single pillar(from my data) value is selected. I would like to achieve two things:
The default or initial chart should show all pillar and the number of projects
Multi selection of pillar values
My main issue is actually the creating the callback for these. Thank you in advance for any help!!
Here is my code
app = dash.Dash(__name__)
all = df.Pillar.unique()
app.layout=html.Div([
html.H1("PM dashboard"),
dcc.Dropdown(id='pillar-choice',
options=[{'label':x, 'value':x}
for x in all],
value='Service Provider',
multi=False),
dcc.Graph(id='my-graph',
figure={}),
])
#app.callback(
Output(component_id='my-graph', component_property='figure'),
Input(component_id='pillar-choice', component_property='value')
)
def interactive_graphs(value_pillar):
print(value_pillar)
dff = df[df.Pillar==value_pillar]
fig = px.pie(data_frame=dff, names='Pillar', values='Project No')
return fig
if __name__=='__main__':
app.run_server()
I think the problem here is that value_pillar will be a list, so you need to do something like:
dff = df[df.Pillar.isin(value_pillar)]
And if you want to show everything by default, you'll need to check the value of that argument for your default value and, if it matches the default, avoid filtering.

How to separate out display and data mxgraph ports example

I am working with mxgraph and using the mxgraph ports example as a starting point for my application. https://jgraph.github.io/mxgraph/javascript/examples/ports.html
The example passes the content of each cell through the value property of an mxcell object. The display content is an html label which is then rendered inside the cell. Example code below shows the creation of an draggable icon on the sidebar the parameters are graph, sidebar, label, image.
addSidebarIcon(graph, sidebar,
'<h1 style="margin:0px;">Website</h1><br>'+
'<img src="images/icons48/earth.png" width="48" height="48">'+
'<br>'+
'Browse',
'images/icons48/earth.png');
The addSideBarIcon function then creates the vertex by passing it's label argument as the value property of the MxCell.
v1 = graph.insertVertex(parent, null, label, x, y, 120, 120);
I would like to be able to add a JSON object to store non display data along with the html label for display purposes in the value property of each cell. I would like to do this without modifying the underlying prototypes.
addSidebarIcon(graph,
sidebar, {
display: '<h1 style="margin:0px;">Process</h1><br>' +
'<img src="images/icons48/gear.png" width="48" height="48">' +
'<br><select><option>Value1</option><option>Value2</option></select><br>',
data: {
key1: val1
},
}
When I do this he code is interpreting the value as an html label. where as I would like it to interpret only value.display as the label. I'm not sure how to go about combining the html label and json data together and would love some suggestions.
You have the implementation of the addSidebarIcon in the same file...
When you find the:
v1 = graph.insertVertex(parent, null, label, x, y, 120, 120);
You have to use there not the "label", but extract the display value from your JSON.

Additional legend or text box window in a plot in octave

I would like to add to my plot a text or a legend box with comments.
At the moment my legend is plot at northeastoutside and i would like to add the new legend (or textbox) to the position southeastoutside.
Thanks!
Lacking more information about your case:
To the best of my knowledge one axes object can only have a single legend object. You can create a second legend with a second axes object. Each legend will only list data elements associated with each axes. Adapted from Matlab Newsgroup thread
a = [1:0.01:2*pi]; %create sample data
b = sin(a);
linehandle1 = line(a,b); %creates a line plot with handle object
axeshandle1 = gca; % gets the handle for the axes object just created
legendhandle1 = legend('y = sin(x)', 'location', 'northeastoutside'); %makes first legend
axeshandle2 = axes('Position',get(axeshandle1,'Position'),'xlim',get(axeshandle1,'xlim'),'ylim',get(axeshandle1,'ylim'),'Visible','off','Color','none'); %makes invisible axes with same position and scaling
linehandle2 = line(pi/2,1,'Color','r','Marker','o','Parent',axeshandle2); %puts data set on 2nd axes
linehandle3 = line(pi,0,'Color','b','Marker','x','Parent',axeshandle2);
legend_handle2 = legend('peak','zero','location','southeastoutside'); %creates legend to go with 2nd axes
If you just want text in that 2nd box, not necessarily legend info or data labels, you can play around with annotation as described above. This has the advantage of being simpler to call, but maybe harder to get the exact position/result you want. There are a large number of property options that can be adjusted to get the desired appearance. A few are shown in the example. It may be there are easier ways to set the size/position based on the legendhandle.
a = [1:0.01:2*pi]; %create sample data
b = sin(a);
plot(a,b);
legendhandle = legend('y = sin(x)','location','northeastoutside');
annotation('textbox',[0.875 0.1 0.1 0.1],'string','my text','edgecolor','k','linewidth',1,'fitboxtotext','off');

R tableHTML add_css text-align centre not working in Shiny

I'm trying to style a table in a Shiny app using the tableHTML package in R.
When I use the tableHTML() function in R it produces exactly what I want. I use the add_css_column to align the text in the column to the centre. However when I use it in a Shiny app the headers end up left aligned and the rows centre aligned. Any ideas how I can fix this?
output$viewers_website_top <- renderUI({
tableHTML(website_index, rownames = FALSE, widths=c(200,200)) %>%
add_css_column(css = list("text-align", "center"),
column_names = names(website_index))
})
This is a common issue with bootstrap 3 unfortunately. Whenever you use shiny it loads up a bootstrap 3 css (immediately) which makes it difficult to overwrite.
As for the solution to this using add_css_header would probably solve this one. add_css_header would change the th tag of the HTML table to the one you like (whereas add_css_header would change the td tags below the headers):
output$viewers_website_top <- renderUI({
tableHTML(website_index, rownames = FALSE, widths=c(200,200)) %>%
add_css_header(css = list("text-align", "center"),
headers = 1:ncol(website_index))
})
Another thing you can do is to add a separate css file with shiny::includeCSS. There is more info here and here on how to use includeCSS.
In the css file you need to write:
.table_website_index th {
text-align: center;
}
And that should do it!
P.S. table_website_index is the class the package assigns to the table which you can also change with the class argument.
P.S.2 I am the developer - thanks for using the package :)

trying to set the text above the Image in ImageTextButton on libGdx

i'm using LIBGDX.
i'm trying to set a text string in the center of an image, and use it as a clickable button.
unfortunately i didn't find a solution for it.
Yes you can with the getLabel method:
myButton.getLabel().setAlignment(Align.center);
https://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/utils/Align.html
By default, ImageTextButton contains 2 Actors in 1 row: Image then Label. To change position of the Label one may rebuild the underlying table cells just after creation of ImageTextButton:
new ImageTextButton(...) {
val label = getLabel
val image = getImage
clearChildren()
add(image)
row() // second row
add(label)
}
Now Label will be under the Image. Code is Scala.