D3.js pie chart labels for slices not tweening - transition

When I click on the various hyperlinks to tween my chart: while the pie's slices are tweening but I cannot figure out how to bring along each slice's label.
A mostly working JSfiddle is here: http://jsfiddle.net/lukateake/MX7JC/
Thanks in advance for any insights you can provide me. I promise to update the fiddle with whatever solution we discover as I imagine this effect is of interest to a great many D3'ers.

The main issue here is in your updateChart function - while you rebound the data to arcs, you did not do so for sliceLabel: (second line added)
arcs.data(donut(data.pct)); // recompute angles, rebind data
sliceLabel.data(donut(data.pct));
One other small thing - your slice label text selection seems a little bit strange:
var sliceLabel = label_group.selectAll("text.value")
but you are creating no text with class = "value"; this doesn't really end up affecting much, but might cause problems in other implementations - selectAll("text") or selectAll("text.arcLabel") might be more appropriate here.
updated fiddle at http://jsfiddle.net/MX7JC/9/

Related

Performance on changing colour of big geojson by using data-driven (comparing to using setPaintProperty)

I have been rendering a FeatureCollection of polygons into the Map (in one GeoJSONLayer). The size of each polygon is big (5mb, 10mb). With user interactions, the colours of polygons would be re-calculated & changed constantly. We are using data-driven method and keeping the data in properties of each feature. So GeoJSONLayer has to call .setData(geojson) everytime the data and colours changed (they are kept in properties).
I find above approach is lead to performance issue since the size of geojsons is big and calling .setData() is expensive.
I'm thinking of separating the geojson source and the data, style, colouring and calling direct function (setPaintProperty) whenever colours changed would be better than.
Someone told me that .setData and .setPaintProperty would do the same thing, both 2 will trigger re-rendering whole polygons.
Kindly need help to advice on this matter
Thanks a lot!
If I understand you correctly, you're asking which of these two is faster:
map.setData(mylayer, mygeojson)
map.setPaintProperty(mylayer, 'fill-color', ...mydatadrivenproperty)
I haven't tested, but I'd assume the second is faster, because the first one has to:
Parse the GeoJSON
Convert it to vector tiles
Repaint
whereas the second just has to parse the property repaint. Try them both out to see.
You may also consider a third way, which is to have a second layer which is a highlight, which you update by calling map.setFilter(mylayer, ...).

Turn Off Point Labels in MS Chart for .NET

VB2010 using MS Chart: I've added one series as a point chart. On occasion there are over 1000 points and the point labels become way too jumbled. I have smart labeling ON:
cht.Series("srs").SmartLabelStyle.Enabled = True
But nonetheless it still looks bad. So I added a context menu to turn off the labels. The user can then zoom in to a spot and if they wish turn labels back on. I cant seem to figure out a way to do this without looping through ALL data points.
I can totally hide the points and labels by
cht.Series("srs").Enabled = False
But I want just the labels to be hidden and then redisplayed when the user has opted for it.
Any help appreciated.
Edit:
Since I haven't found a method to turn labels off and on with one command I am currently cycling through each point in the series.
Me.Cursor = Cursors.WaitCursor
Application.DoEvents()
'suspend updating UI
cht.Series.SuspendUpdates()
'cycle through all points in the series and set the label either to an empty string or whatever is cached in the Tag property.
'todo: this is not efficient for large datasets but its the only thing we have.
For Each pt As DataPoint In cht.Series("srs").Points
If mnuDisplayLabels.Checked Then
pt.Label = pt.Tag.ToString
Else
pt.Label = ""
End If
Next pt
'resume updating UI
cht.Series.ResumeUpdates()
'force redraw of chart
cht.Update()
I think you have to loop, but you want to suspend updating the UI until you've done it for all points. Try something like:
chart1.Series.SuspendUpdates();
foreach (Series s in chart1.Series)
{
s.IsValueShownAsLabel = false;
}
chart1.Series.ResumeUpdates();

iOS-Charts: How to include a gap between data points & lines

I'm using iOS-Charts with Swift to draw line charts, and I'm looking for a way to place a gap between the data points (circles) and the lines themselves.
Something like this: example
I've tried playing around with some values under the drawLinear section of LineChartRenderer.swift, but I don't know enough about Core Graphics to do anything useful.
Having a white outline for the circles is unfortunately not an option, since I'm displaying multiple datasets with images containing transparent layers, and the datasets need to be able to overlap (as in the example image)
Any help would be greatly appreciated - thanks :)

Leaflet.js display of a non-geo map (gdal2tiles.py) – I need a concrete example

I'm displaying a map that's been tiled (-p raster) using gdal2tiles.py. The X-coordinate is about [0..-1160]. The Y-coordinate, for some reason, is [-700,0]. Zoom-levels 0-5.
I simply cannot get a plausible display to work. Sometimes, if I zoom-out to level-zero, I see the map way down at the bottom of the display ... not centered. Nothing at all appears at other levels.
I am also seeing the display "bounce back and forth" between about a 3-o'clock and a 6-o'clock position. (Only, once again, at zoom-level zero.)
I am at my wit's end. Please give guidance. Complete examples. Anything ...
Well, I found my answer:
If you're going to be using several layers in your Leaflet map, add them in the constructor-call, using the layers parameter.
If you try to do things with the layers before joining them all together, or with the map with no layers added, "strange and default things will happen." (For example, although I requested the Simple CRS when constructing things (separately...), the net-effect was to actually try to use a different one. Therefore, "do what the author expected." Specify all the layers at once, to the Map constructor. Then, customize them as you need to. Make very sure that they all know about each other from the very start of things.

How to update data changes in an already drawn SPSS graph

I have drawn several bar chart, scatter, and line graphs in SPSS 21 and spent lots of time on editing their look. But, I realized that I made some mistakes in data and they are already changed. In Microsoft excel, graphs are interactive/dynamic, meaning that they change if you modify the values of each cell. Can we mimic the same feature in SPSS 21? Is there any way I can update graphs without redrawing them from the scratch? I have saved them as output, but when I load them no change is reflected and the graphs are associated with old data.
I have saved syntaxes to produce the graphs, but when I run the syntax, the graphs are produced in standard looking that need lots of changes to look good. When I save chart templates and apply them to new charts, they don't look the same meaning that some of the changes are not applied.
Please help.
It is not possible. I feel you with making all the changes and the inconsistency in applying chart templates though. A few tips to mitigate this in the future are;
Do everything you can with GGRAPH and inline GPL statements to get the look of the chart close to how you want it.
Start with a chart template that is closer to your typical end goals. (See here on how to make some simple edits to the default template).
Some things are still difficult to fully automate like label placement in the chart. These simple tips though get me very close to the end goal, and only rarely do I need to take the time to polish a chart with editing post-hoc.