slopegraph | Edward Tufte 's Slope Graph
kandi X-RAY | slopegraph Summary
kandi X-RAY | slopegraph Summary
An implementation of Edward Tufte's Slope Graph in javascript using Raphaël
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
Currently covering the most popular Java, JavaScript and Python libraries. See a Sample of slopegraph
slopegraph Key Features
slopegraph Examples and Code Snippets
Community Discussions
Trending Discussions on slopegraph
QUESTION
I am using OOP principles to create a bunch of graphs. Everything works fine except the setting of text values. I need to set the title of each graph but instead I am getting blank values.
My code: The controller file, i.e. main.js
does all the data manipulation and creates new graphs by invoking the constructor function (stored in mainSlopeGraph.js
) with arguments that include the id
of
Relevant code:
...ANSWER
Answered 2020-Mar-16 at 17:22In your HTML you use provinceNameKPK
and alike, in your js however you use provNameKPK
.
So
QUESTION
I am creating a slope graph but it's being squeezed into one tiny box despite having plenty of SVG space.
Following the normal process, I created a larger canvas that holds all the elements of graph (including labels and axes etc) and then using margins, created a smaller canvas that holds ONLY the graph (no axes but incl some labels).
Then using a linear scale, I added the lines expecting it to take up all the space inside the larger canvas minus the margins.
However, instead the graph is being squeezed into a much smaller box and I cannot tell why. It's causing all the labels to overlap each other. Also, it looks awful because one of the axes is falling exactly where it should, which means it's really far away from graph.
I have tried changing various aspects of the code including expanding the range()
of the linear scale but it causes only the smallest change (i.e. the lines expand a little away from each other) which is even more confusing.
I also tried commenting out all the code that moves labels around to prevent them from overlapping in case that was causing the unexpected results. But that wasn't the problem.
Clearly, something else is causing the y
values to be confined to a smaller space than is apparent. I did copy this code from somewhere else so maybe I missed something when I modified it for my own use: https://gist.github.com/mwburke/9873c09ac6c21d6ac9153e54892cf5ec
My own code:
...ANSWER
Answered 2020-Mar-13 at 14:38I made the mistaken assumption that my dataset values ranged from 0-100 (because it was a percentage column) but actually all the values were actually between 40-75. Once I adjusted domain to be .domain([40, 75]), the lines spread out as expected.
Now I have to make other decisions about whether graph is misleading without 0% value on the axes. But this issue can be closed out.
QUESTION
I'm working on a chart similar to a slopegraph, where I'd like to put labels along one or both sides with ample blank space to fit them on both sides. In cases where labels are very long, I've wrapped them using stringr::str_wrap
to place linebreaks. To keep labels from overlapping, I'm using ggrepel::geom_text_repel
with direction = "y"
so the x-positions are stable but the y-positions are repelled away from one another. I've also got hjust = "outward"
to align the left-side text at its right end and vice versa.
However, it seems that the repel positioning places the label's bounding box with an hjust = "outward"
, but the text within that label has hjust = 0.5
, i.e. text is centered within its bounds. Until now, I'd never noticed this, but with wrapped labels, the second line is awkwardly centered, whereas I'd expect to see both lines left-aligned or right-aligned.
Here's an example built off the mpg
dataset.
ANSWER
Answered 2019-May-07 at 20:09TL;DR: probably a bug
Long answer:
I think it might be a bug in the code. I checked the gtable of the plot you made, wherein the hjust
was specified numerically and correctly:
QUESTION
ANSWER
Answered 2019-Mar-29 at 12:17One potential option would be to change the class of df$type
and set the order prior to plotting. Like this:
QUESTION
I want to shrink the plot area so there is more room for ggrepel
labels that currently get cut off. I can't seem to offset the labels any more via nudge_x()
, and I do not want to shrink the text size.
I'm trying to find a way to compress the chart so that the groups all move closer to the center, leaving more room for labels at the extremes of the x-axis.
Specifically, I am trying to knit this figure into a portrait PDF. I tried controlling fig.width
in the chunk options, but this just made the entire chart smaller.
I want to maximize the width on the portrait page, but shrink the plot area relative to the area for labels.
...ANSWER
Answered 2019-Mar-27 at 19:47One option is to save your plot as an object (p
) and then use the set_panel_size
argument in the egg
package to explicitly set height and width of the panel (as done in this answer). Something like this gets you close:
QUESTION
While creating a slopegraph with ggplot2
, as below, I find that many of my labels overlap when their data points are close together. How can I change the labelling to automatically stagger my labels if there is overlap?
ANSWER
Answered 2017-Nov-21 at 20:51Since the teams that overlap have the same winning percentage, you can deal with overlap more simply by combining the labels for teams with the same winning percentage. I've also made a few other changes to your code intended to streamline the process.
QUESTION
I'd like to make a slopegraph, along the lines (no pun intended) of this. Ideally, I'd like to do it all in a dplyr-style chain, but I hit a snag when I try to subset the data to add specific geom_text
labels. Here's a toy example:
ANSWER
Answered 2017-May-16 at 17:47Writing:
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install slopegraph
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page