[jqplot-users] OHLC date gaps

599 views
Skip to first unread message

Vilo

unread,
Apr 26, 2010, 11:57:58 AM4/26/10
to jqplot-users
I am using jqPlot to render candlestick stock charts. In OHLC
candlestick samples, charts are built upon consecutive data. However
when I use real data from .csv feed, historical data are not
consecutive numbers. This is because there are weekends when stock
market is closed. When using DateAxisRenderer and xaxis tickInterval:
"1 day", it creates 2 day gaps on chart for every weekend when there
are no data. So when I am trying to plot chart for last 10 days, there
are 2 empty slots after every 5 days of data.

I tried to find the info on jqplot site on how to remove these gaps.
However I could not find a way to do so. Would you be so kind and
point me to direction on how to make OHLC candlestick chart look
seamless like in examples with actual data that have those weekend
gaps in dates.

thanks for any direction in this matter

--
You received this message because you are subscribed to the Google Groups "jqplot-users" group.
To post to this group, send email to jqplot...@googlegroups.com.
To unsubscribe from this group, send email to jqplot-users...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/jqplot-users?hl=en.

Narcélio Filho

unread,
Apr 28, 2010, 11:32:58 AM4/28/10
to jqplot...@googlegroups.com
I tried to find the info on jqplot site on how to remove these gaps.
However I could not find a way to do so. Would you be so kind and
point me to direction on how to make OHLC candlestick chart look
seamless like in examples with actual data that have those weekend
gaps in dates.

  I hate those gaps too. What I do is to use CategoryAxisRenderer instead. Like:

$.jqplot(chart_name, series_data, {
    // ...
    axes: {
        x2axis: {
            renderer: $.jqplot.CategoryAxisRenderer,
            tickOptions: {
                formatter: date_formatter,
                labelPosition: 'end',
                angle: -90
            }
        }
    // ...
    }
}

    // ...

    date_formatter = function(format, val) {
        if (typeof(val) === 'number') {
            return series_data[0][Math.round(val-1)][0];
        }
        return val;
    }





-- 
[]s, Narcélio
ohlc.png

Chris Leonello

unread,
Apr 28, 2010, 10:38:23 PM4/28/10
to jqplot...@googlegroups.com
The date axis renderer is a linear monotonically increasing axis, so It will always have gaps just as the data 1,2,3,5,7,8 will have gaps.

Narcélio has the right idea to try a category axis.  Note that you can use the date axis formatting functions outside of the date axis renderer.  Include the jqplot.dateMethods.js file and then you do something like:

var d = Date.create(timestamp or date string);
var formattedString = d.strftime(format string);
--
Chris Leonello
ohlc.png

Rodrigo

unread,
Oct 5, 2012, 4:19:26 PM10/5/12
to jqplot...@googlegroups.com
I think that Category Axis is not a solution, because you transform dates into categories and you lost zoom over that axis.

The solution would be a Date Axis with gap remover option.

Alexander Petrichkovich

unread,
Sep 4, 2014, 4:09:46 PM9/4/14
to jqplot...@googlegroups.com
Use this solution http://stackoverflow.com/questions/7204232/flot-show-time-axis-without-gaps

пятница, 5 октября 2012 г., 23:19:26 UTC+3 пользователь Rodrigo написал:
Reply all
Reply to author
Forward
0 new messages