dimple.js - modify shape to be unfilled bubble depending on value of 'Channel' - dimple.js

Looking for suggestions on how I can modify the example dimple.js code in link below so the output is a filled/unfilled circle depending on the value of the 'Channel' variable?
http://dimplejs.org/examples_viewer.html?id=bubbles_vertical_grouped
Picture below is an example of the result I am looking to achieve.
result looking for

You can just do:
chart.assignColor("Supermarkets", "transparent", "blue");
Where the third parameter is whatever you want the outline colour to be. If you want thicker borders like your picture you can do that after drawing with:
svg.selectAll("circle").style("stroke-width", 5);
To be a bit more specific you can assign the series to a variable and access them that way:
var series = myChart.addSeries("Channel", dimple.plot.bubble);
myChart.draw();
series.shapes.style("stroke-width", 5);
Or you can set the stroke-width in CSS.

Related

How to incorporate keys or dataframe column names in plotly express custom hover text?

Lost as I can be on how to control hover text with embedded data.
Non-dataframe scenario
In one case, I am passing a list of dicts to a plotly express (scatter) plot, having the shape:
list[dict[str, float]]
and I would like the hover text for each point to include its key from the dict inside my own domain-specific phrasing for the hover text.
When not tampering with the hover text, the default hover text showing up includes the key following the string "variable", and the x and y values being called "index" and "value" accordingly there in the default hover text. Obviously the x value is just the index of the dict from the list for input shaped as in my input type.
But incorporating these values with names bearing the semantics of the data seems to pose a challenge, as including something like follows does not really plug in (by substitution) anything but the x and y values in the percent prefix bracelets:
fig.update(data=[{'hovertemplate': 'distance: %{y} (class %{variable})'}])
For example, %{variable} will show as just the string as is, it will not substitute this string with the value of what the default hover text calls "variable".
How would I incorporate the "variable" value, as called in the default hover text, in my own hover text specification?
I went through numerous documentation pages where this is accomplished via plotly's non-express api or other ways which didn't seem to work for me. It's in general elusive to adapt any of the dataframe based solutions to my dataframe-sidestepping case. I wonder if there's an idiomatic way.
DataFrame based scenario
In another case, switching to dataframe input, I still battle to get the desired column name be recognized as, I wander in the plurality of ways to handle hover text and data for plotly:
fig = px.scatter(df, x='x', y='distance', color='class')
fig.update(data=[{'hovertemplate': 'distance: %{y} class %{class}'}])
fig.show()
― %{class} in the above dataframe oriented approach, is obviously not the proper way to select the class column's value for the hover data. How would I bring in the value of the desired dataframe column name into the hover text?

Change color of distribution plot in qlik sense

I have a distribution plot in qlik sense:
How can I specify the color of the dots? I want to change it based on the points.
I have three different types of my x-axis 'Geschäftsverteilung' : 'On-Time', 'Delayed' and 'Late', so the on-time are red right now and should be green, the delayed are blue and should be yellow and the late ones are yellow and should be red.
You need to set to change colors by expression something like that:
If(Sum([# Purchases]) > 6,Green(),Red())
To provide exact answer I would need to see your file and know what exactly you want to achieve (what colors for what results)

How to assign a label to go.layout.Shape(type="line"...)?

I produce the following figure.
The figure has a number of add_trace applied to it with go.Scatter as arguments.
A list of 4 go.layout.Shape, type="line", with fixed color attributes, is created and the figure layout is updated with that list: fig.update_layout(..., shapes=...)
The traces have labels assigned to them that we can see to the extreme right.
Is there a way to add labels to assign to the lines as well?
You would like your lines to appear in the legend of the figure (https://plot.ly/python/legend/). However, only traces can appear in the legend, not shapes which are a kind of annotation. What you could do is to create the lines using go.Scatter(..., mode='lines'), and then they would appear in the legend. You just need to give the starting and end points in go.Scatter (see https://plot.ly/python/line-and-scatter/).

Can I find bordercolor of a field in PDF using iText?

Is there anyway of finding the bordercolor of a specific field in my PDF using iText latest version? I could get AcroField.Item, but I dont see an option to get bordercolor from there.
Please take a look at this PDF: text_fields.pdf. This PDF was created using the TextFields example. The following code snippet was used to set the border of the field with name text_2:
text.setBorderStyle(PdfBorderDictionary.STYLE_SOLID);
text.setBorderColor(BaseColor.BLUE);
text.setBorderWidth(2);
Now when we look inside the PDF using iText RUPS, and we take a look at the field dictionary / widget annotation for this field, we see the following structure:
We see a /BS dictionary that defines a solid border style (the value for the /S key is /S) and a border width (/W) with value 2.
We also see that the border color (/BC) entry of the /MK entry is an array with three values: [ 0 0 1 ]. This means that the border color is an RGB color where the value for Red is 0, the value for Green is 0, and the value for Blue is 1. This is consistent with us setting the color to BaseColor.BLUE when we created the file.
You say that you have the AcroField.Item object for a field. Now you need to get the merged field / widget annotation dictionary and follow the path shown by iText RUPS:
AcroFields.Item item = acroFields.getFieldItem(fldName);
PdfDictionary merged = item.getMerged(0);
PdfDictionary mk = merged.getAsDict(PdfName.MK);
PdfArray bc = mk.getAsArray(PdfName.BC);
The values stored in the array bc will inform you about the background color. If the array has only one value, you have a gray color, if there are three, you have an RGB color, if there are four, you have a CMYK color.
Warning: some values may not be present (e.g. there may be no /BC entry). In that case you can get NullPointerExceptions.

What is "index" in NSGradient getColor:location:atIndex?

In the following NSGradient method:
- (void)getColor:(NSColor **)color location:(CGFloat *)location atIndex:(NSInteger)index
What is index? The documentation says index of the colour I want. But I thought the point of this method is that it tells YOU the colour to use for a particular location ? I don't know the index.
I want to define a gradient (colors and locations), and given a float return the corresponding colour.
Does anyone have an example where a gradient is defined, and this method is called ?
As the docs say,
This method returns the color stop information that was used to create the receiver. It does not return the interpolated color values at any point along the gradient.
The index is into the initial array of colors that you used to create the gradient. The location parameter isn't one that you pass in; it's an out parameter like color, and will give you the location (which you also specified when creating the gradient) associated with the color stop at the index you pass.
It sounds like you're looking for interpolatedColorAtLocation: