Comments (7)
Just wanted to update everyone on how I solved this problem which is just to add the x- and y-axis labels in regular HTML and position them with CSS.
Here's the actual code I used which is kinda verbose for the purpose of this discussion but the Peity chart has id="barChart"
. Also just FYI, the numbers are printed using PHP ($totals
is the variable name of array which is turned into the comma-delimited string using implode()
).
<li style='margin: 0;' title='<? $max= max($totals); echo $max?>=max purchases per month' class="nicetime"><?=$max;?></li>
<li style="padding-left: 5px;" id="barChart"><?=implode(',', $totals);?></li>
<li style='margin: 0;display:inline ' title='<? $min= min($totals); echo $min?>=min purchases per month' class="nicetime"><?=$min;?></li>
<li style='display:inline ' class="nicetime"><i class="icon-bar-chart icon-gray txt14"></i> 52-week views+listens</li>
from peity.
There isn't and I think it would be difficult to implement I'm afraid. I think it would be trivial if only it were SVG and not canvas...
from peity.
i figured this much. For what its worth, jquery.sparkline which is also <canvas>
based has this functionality: http://omnipotent.net/jquery.sparkline/#s-about.
It might we worth checking out to see how they added this to their graphs. jquery.sparkline is a 129kb file but the 124kb difference can't entirely due to rendering that data.
from peity.
Thanks, I'll take a look. I've actually been thinking about this recently but had mostly decided it'd be more kb than it's worth, I may re-evaluate though.
I was also thinking about making an SVG version - though that was before I added "retina" support.
from peity.
I was able to add it very simply at least for pie charts. You can adapt this snippet easily enough. Cheers.
$chart = $('span#by-week + svg.peity')
barWidth = chartWidth / data.length
for value, i in data
attr =
x: i*barWidth + barWidth/2
y: chartHeight-15
width: barWidth
height: 20
fill: if i >= data.length - @weeksRemaining then 'rgba(255,255,255,0.2)' else '#ffffff'
style: 'text-anchor:middle; font-size: 12px'
$text = $(document.createElementNS 'http://www.w3.org/2000/svg', 'text').attr(attr).html(value)
$chart.append $text
from peity.
Thanks for bumping this!
Now that it's SVG I think this would just be a case of adding an attribute (probably data-value
?) to each element that you can then read leaving you to use your own favourite tooltip library 😄
from peity.
that would be really nice.
from peity.
Related Issues (20)
- Change data-value to label
- data-value not working with "bar"
- Any react-native port?
- Required Two different color in Line chart HOT 1
- points calculated wrong in DataTables cell HOT 2
- can it have lables HOT 1
- Add ability to use CSS classes on SVG charts HOT 2
- jQuery version and Peity version always conflict HOT 2
- innerHTML to Span HOT 6
- Adding composer.json and submitting to packagist HOT 4
- Smooth animate pie chart on update HOT 2
- when using with bootstrap HOT 4
- This project should be renamed to piety HOT 1
- Charting fractional values HOT 1
- Add a mouseover to view data HOT 1
- Stacked bar HOT 1
- Any way to know if the numerator is greater than the denominator in a pie with delimiter /? HOT 2
- Semicircle donuts?
- show percentage in center donut HOT 1
- Further custom styling
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from peity.