How to bypass FastClick with Kendo UI DataViz Chart - kendo-ui

We have a web app that is used with iPads and iPhones. We are using FastClick (https://github.com/ftlabs/fastclick) to eliminate the 300ms wait time for mobile/tablet users.
This makes everything snappier, but the interaction with the chart (using SVG rendering) is spotty. Sometimes tapping works, sometimes not. ​Users need to be able to do normal chart interactions like tap a point to see the value and toggle series on/off in the legend. If I disable FastClick, chart tapping works fine.
FastClick has a built-in way to bypass an element. You add the "needsclick" CSS class, and it leaves that element alone. I put this CSS class on the div the chart is rendered in, but each clickable element in the chart apparently also needs to have the "needsclick" class added to it.
Is this possible?

I gave up. I added "needsclick" to all SVG elements after the chart rendered, and the iPad clicking was still really weird. Sometimes it worked, but not consistently.
I think these libraries are both trying to solve the same problem and stepping on each other to do it, so I removed FastClick.
This was with FastClick 1.0.6 and Kendo UI v2015.1.408.

Related

Charm 4.0.1 possibility to disable layout adjustment when keyboard shows up

I'm facing several problems with the new function which is responsible for adjusting the view layout, when the keyboard shows up.
For example when a DatePicker is shown while a TextField is focused:
Is there a possibility to disable this function?
EDIT:
While removing the focus from the TextField before the DatePicker is shown works, there are still some others issues so I would prefer to use my own custom solution AndroidNodePositionAdjuster.
Another issue e.g. is an unpleasant white area (which will be covered by the keyboard), when the view is transitioned upwards to make room for the soft keyboard, so the transition appears very unsmooth:

How can I add a scroll on the Zingchart-grid?

I want to scroll would need to add some code cause the scroll?
The grid module included in the ZingChart library is a read-only grid. It does not include any interactive features like scrolling.
We are working on a much more interactive grid with tons of features. Hopefully that will be available in the next few months.

Set scroll bar in third party API using CSS

In these image,the image which is in green color is not fully displayed.Because I am using third party API for these design. That third party API does not contain scroll bar in it. So, I create scroll bar using css3. After creating custom scroll bar third party API is not supported properly on full page. So these is my problem.
Is there any way I can solve this problem using CSS.
ohk i got your question that you added scrollbar on css but it not work on green images. (y) now you have to check that which div or tag you target scrollbar. you have to check which content or div that you want to scroll automatically so you have to find class name or div tag apply scrollbar on it. you applied scrollbar at wrong place so check code again :) or give me code of it so i will correct it

NVD3 Charts not rendering correctly in hidden tab

I am building a page which contains many charts, which are displayed one at a time depending on which tab you are looking at.
The chart in the initially active tab renders correctly. However when I click to another tab, the chart is not rendered properly.
Presumably this is because the hidden field does not have dimensions until it is made visible. In fact if I resize the window the chart will correct it's proportions, and render so that it fills the available width.
I can fix this problem by explicitly defining the chart size via css, but this defeats the responsive aspect of the charts.
Can anyone tell me how to trigger the same NVD3 event which gets activated when the window resizes? That way I can bind it to the selection of a new tab, and hopefully remedy the rendering issue.
I had the same issue (charts on multiple tabs), and this is the only thing that I could get to work.
$(function () {
$(document).on('shown.bs.tab', 'a[data-toggle="tab"]', function (e) {
window.dispatchEvent(new Event('resize'));
});
});
I have a feeling, however, that all of the charts are being re-rendered, regardless of whether they are on the active tab (visible) or in the non-selected tabs (hidden).
Does anyone know how to ensure ONLY the active chart gets resized / redrawn?
I figured out how to trigger the resize event I needed. In my case the tabs are driven by bootstrap. So I simply modified my bootstrap show tab event to trigger a page resize event as well. It's a little indirect, but it gets the job done:
jQuery('#myTab a').click(function (e) {
e.preventDefault()
jQuery(this).tab('show')
jQuery(window).trigger('resize'); // Added this line to force NVD3 to redraw the chart
})
Just add this JavaScript:
$('a[data-toggle="tab"]').on('shown.bs.tab', function (e) {
window.dispatchEvent(new Event('resize'));
})
hidden.bs.tab is the event that fires after a new tab is shown as per the Bootstrap docs. This code fires a resize event after each tab change.
Reason For New Answer
Vanilla Javascript is necessary for a lot of people in 2018. As a lot of frameworks and Javascript libraries that exist today do not play well with jQuery. Once upon a time answering all Javascript problems with a jQuery solution was acceptable but it is no longer feasible.
Problem
When loading C3.js or D3.js graphs, if the viewport is not actively in site during page load the graphs do not render correctly.
Example
If you type in the URL then open a new tab and then go back after your page loads.
If you refresh the page that has your graphs on it then minimize the browser and open it back up after the page has loaded.
If you refresh or go to the page with the graphs then swipe away to a new window on your computer. Then go back to the page with the graphs after they have loaded.
In all these cases your C3.js / D3.js graphs will not render correctly. Typically you will see a blank canvas. So if you were expecting a bar chart, you would see a canvas without the bars being drawn.
Background
Although I have seen this question answered I needed an answer that did NOT use jQuery. Now that we have reached the days of everything can not be fixed with jQuery I thought it seemed fit to provide a vanilla Javascript answer to this question.
My team faced the issue that the C3.js / D3.js graphs would not load if you refreshed the page and swiped away or minimized. Basically if you did not stay on the page and keep it in site till it was done loading you would not see the graphs till you resized the page again. I know this is a problem that happens to everyone using C3.js / D3.js but we are specifically using Lightning in Salesforce.
Answer
Our fix was to add this in the controller function that initializes the charts. Anyone can use this in any function they write to initialize their C3.js / D3.js graphs regardless of their stack. This is not Salesforce dependent but it does indeed work if you are facing this issue in Salesforce.
document.addEventListener('visibilitychange', () => {
console.log(document.visibilityState);
window.dispatchEvent(new Event('resize'));
});
I was facing same issue. I was using ng-show to make div hidden . Once I replaced ng-show with ng-if I am able to see graph drawn in expected behavior. Explanation:
When we use ng-show or ng-hide to make div hidden it only changes it display property but div will be in dom.
When we use ng-if div is removed from dom and again added to dom so internally it performs redraw operation on nvd3 graph too. Hence we see correct graph instead of squished one.
The event that usually triggers a redraw is the window resize event -- NVD3 doesn't use a custom event for this. You can control this yourself though; the usual definition is
nv.utils.windowResize(function() { d3.select('#chart svg').call(chart); });
(where "#chart" is the element that contains the graph). There's nothing stopping you triggering the code on another event or even just running the redraw code explicitly when you change the tab.
a more efficient approach would be to use the chart.update() method
var chart_x = nv.models.somechart()
var chart_y = nv.models.somechart()
..... show charts
jQuery('#myTab a').click(function (e) {
e.preventDefault()
jQuery(this).tab('show')
if(jQuery(this)...something === '..x..')
chart_x.update(); //CALL THE UPDATE
else ...
})

What's wrong with my jQuery plugin? (Won't animate)

I'm building my first jQuery plugins. One is a tab-views switcher thing, and the other is a sliding pager thing. They can both be seen on this test page: http://test.benlwilliams.com/powerwash/
The problem I'm having is with the slider plugin called, blwslider(). The implementation can be found at the bottom of the test page.
I want to be able to have any number of sliders to be independent of one another. The slider on the top works perfectly, but the slider on the bottom will not animate the sliding.
The bottom slider has 2 pages, and starts on the first page. You can see by clicking on the arrows that they appear and disappear correctly, as if the page had turned, but no animation is actually happening to turn the page. What makes me really confused is that if I use Firebug and put some "stops" in the turnPage function, all the variables have the correct values. I can't find any reason why the page is not turning.
I also considered that maybe only the first appearance of a .blwslider() is working for some reason. But I already swapped the order of the two chuncks of slider code, and still the slider with the #slider2 chunck refuses to work.
All the code is visible with firebug, but let me know if I need to post something specific. Thanks!
So it turns out it has nothing to do with the plugin's implementation or structure, but rather a math problem when the slider has only two pages.

Resources