Histogram slider in Javascript - jquery-plugins

I am trying to build a slider filter, which enables users to select a numerical range of a filter. I want to add a histogram image(i.e. svg) as a background of the slider. Currently I am considering d3.js or jQuery Sparkline, and a jQuery slider or HTML5 native slider element. Can someone give any suggestions on Javascript library?

Compare:
<input type="range">: native, does not require an extra library.
jQuery slider: Cross-browser, can have much control over the appearance.
Sparkline: a jQuery plugin, even more control (never use it, can't tell)
The most important thing is, depending how you are using it, choose the one that best fit your purpose. Sometimes a simple jQuery slider is enough, but in some case a plugin might do even more.

Related

Override styles for axes and legend dc.js

I will like to override the style for charts in dc.js
I want to change, fonts, colors, font-weights, for axes, legends, and similar.
What is the best way to make this changes, without modifying the lib?
Styles/elements that are not driven by data
Anything that is not driven by data is best modified by using CSS. I usually just use the browser's inspector/developer tools to determine the correct selectors to use, but you can also get some clues by looking at the sass source for dc.css.
All of the visual attributes you list above fall in this category. Generally anything that is outside of the plot area is not data-driven.
Many of the visual attributes for things inside the chart are also not data-driven. For example, if you wanted to change the text labels inside the plot area, those styles all come from dc.css and are best modified with CSS.
Styles/elements that are driven by data
For changing anything that is data-driven, using a pretransition hook is going to be the best way - this fires after a render or redraw when all elements have been added or removed (but before they transition from old values to new values).
The form for this is
chart.on('pretransition', function(chart) {
chart.select('something').attr(...);
});
where something is a selector like rect.bar - in-chart selectors are starting to be documented in the Wiki.

Controlling the drop down list width in IE8 on select

Is it possible to control the drop down list width on select in IE8?
When the page loads I want the drop down list to be small enough to only contain the word SELECT, but when the user clicks on it to make the selection, it should expand enough to make sure all the choices are fully visible, widthwise.
FF does it, IE9 does it. But IE8 cuts off the width.
Any fixes?
thanks
Just try to include below CSS.
select:focus{width:auto !important;}
I hope it solves your problem.
For IE8 you will need to use some JavaScript for this. There are JQuery plugins that do this too, but I think there is no work around without using js.
Take a look at this other SO thread for different approaches and js libraries you might use.
In my experience, the best solutions involve replacing the select element with some other HTML, CSS and JavaScript combination, as trying to change the width of the original select on certain events will move the content on the right of it.

webkit slide in and slide out a page

I'm new to webkit animations and I have been trying out to do this kind of animation
http://demo.jeffrey-way.com/tutsMobile/#site.php?siteName=psdtuts
If you click the list element you will see page sliding in and sliding out.
I want to implement this animation to my app which is built with backbone.js, underscore.js, zepto.js
I could use jqTouch or jquery mobile but I would like to make it as light weight as possible, because I'm building it only for IOS. So thats way I wan't to implement it by my self.
Any hints to make this implementation or should I go with jqTouch?
In this example, there is some sort of (I hate to be vague...) ajax based content loading system. Take a look at the source:
<div data-role="page" id="article.php?siteName=psdtuts&origLink=http%3A%2F%2Fpsd.tutsplus.com%2F%3Fp%3D15026" class="ui-page ui-body-c">
When you first visit, that div doesn't exist. It's created by javascript when content is required, then filled with that content, then translated (animated) into the viewport.
Here is a step by step, deduced from a quick look at the page:
Base page is loaded, including css, javascript, nav list
Script is waiting for a nav item to be clicked.
Upon clicking, an ajax request is made to the content corresponding to the clicked item; determined by href="article.php?siteName=psdtuts&origLink=http://psd.tutsplus.com/?p=15081". My guess? This ajax request is getting content from the same place as psdtuts.com, likely in a database.
While that stuff is loading, javascript shows a loading animation. When loading is complete, it's hidden again.
Once the new content-filled div is created, it is given a default position with its left edge placed right outside of the right edge of the screen. Upon the event of being positioned, javascript then determines the view's dimensions and translates the div across the horizontal dimension. At the same time, the nav list is moved the same direction and distance.
When back is clicked, the view's dimensions are determined again (In case the window size changed) and the nav and content are translated to the right, hiding the content and showing the navigation again.
Repeat
I could be off from how this exact sample is being done, but... Well, this would work.
You wouldn't be that crazy to use a framework for something like this, but I can understand wanting to do a custom job. It would certainly be faster for users, but slower for you. Depending on your intent, that would be just fine.
edit: If you're only serving this to users with webkit, using a framework is even less necessary... If you're not worrying about cross browser support, there's really not a lot going on here that you couldn't accomplish easily with raw javascript.
The only reason I use jQuery for example, most of the time, is to ensure things work alright in most use cases. It just smooths so many things out... Even if 95% of the framework isn't being utilized, it's worth it when you've got a deadline.
I founded out one good example
http://andrew.hedges.name/blog/2009/05/29/animating-your-iphone-web-application

Can you preload images in a dojo animation

I have a dojo animation object of about 15 images. I'm also using dojo.fx.chain to link them all together.
Right before I create all my dojo.fadeIn's and dojo.fadeOut's I added in some basic javascript to preload each image.
My question is: Am I doing this the hard way or is there some function/attr I can set in the animation object to do this?
I do not think there is a predefined method in dojo to preload these images for your animation.
I guess you are listening image.onload and image.onerror events to preload images, it is a common method. If you feel it is too difficult and hard to control, you can try a simple clean css way that is to put an invisible div into your page and set background images with these animation images. When the page load, the images are automatically loaded.
dojo Animations are not specifically geared around images, they work on an abstract level and may operate on DOM nodes. So, there's no built-in support for IMG nodes specifically.
There is dojox.image.preload (http://api.dojotoolkit.org/jsdoc/HEAD/dojox.image.preload) which will do the work virsir suggested of loading images into an offscreen div, but it does not (currently) arrange an onLoad event hook for you to detect when they're loaded and thus play your animation.
I imagine you could use preload()'s return value and use it to hook into onLoad, but that's an exercise for the reader. Have a look at the source code, dojox/image/_base.js.

Non-traditional input using CSS sprites and JavaScript: opinions sought

My client is very invested in using a bunch of non-traditional inputs in a form we are developing for him. The image below represents various states of the interface with the last indicated it is disabled in the current context. The end users will be trained in how to interact with the inputs.
alt text http://www.nolaflash.com/interface.gif
My idea is that we will develop an image map representing the clickable zones of the image and let the onclick event set a hidden field and change the CSS for the element to move the background sprite to the appropriate coordinates.
What do folks think of this? Obvious flaws other than folks with JavaScript disabled?
I want the end solution to be iPhone/other device friendly.
Your thoughts will be appreciated.
let the onclick event set a hidden field and
change the CSS for the element to move
the background sprite
sounds reasonable
Here is my solution using CSS Sprites and JS
http://egolfplan.com/testform.html

Resources