Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor chartSeries() function to be a wrapper for chart_Series() function #95

Open
wants to merge 12 commits into
base: master
Choose a base branch
from

Conversation

erichung0404
Copy link

chartSeries() function is now a wrapper for chart_Series() function so S4 method and objects, chob and chobTA, are deprecated. That means chartSeries.chob() function and chartTA() function are no longer available as well. Since chartSeries() has more detailed arguments than chart_Series(), mostly color settings, main changes are matching the parameters created by chartTheme() function with parameters of chart_theme() function that already exist in plot_object$Env$theme and passing those arguments to the plot object. Minor ticks setting of chartSeries() is different from its default setting in plot.xts() so the action is rewritten to make minor ticks downwards and space for both sides is reserved.

Remain the code that handles argument differ from chart_Series
in the original chartSeries function. Parameters created by chartTheme()
are passed to the plot object and coordinate with parameters created
by chart_theme(), theme$BBands, for example.
Add legend to show the last close price of series.
As the direction of minor ticks of the original chartSeries is downward,
the second action of replot_xts-class object is modified to reach that.
To create the chart the same as quantmod::chartSeries, border of
plotting area and inbox color are applied.

Remove x-axis grid line.
In the original chartSeries, space of left and right sides is reserved.
x limit is reset to reach that, which makes the chart more readable.

Change inbox color from theme$fill to theme$area.

Since the inbox area is behind of horizontal ticks and border should be
on the top of the ticks, border is added after the ticks and the inbox
area.
Add TA functionality to handle "addVo()" argument. If Volume is not
included in x, "addVo()" will be removed from TA.

Allow TA=NULL to work.
To coordinate with addPoints(), when x is specified by numeric vector and
without subsetting the intersection of x and the index of series will be
FALSE because xsubset is always "". It should be the index of the raw series,
namely, 1:NROW(x), which is also the original setting in chartSeries.
When reChart is called to draw subset series, minor ticks on xycoords$x
do not change with the subset sereis.

Fix xycoords$x to be xycoords$x[1:NROW(xsubset)] in the x-axis expression.
Since "Volume" is not included in xts series, show.vol will be FALSE and
grep("addVo()", TA) returns 'integer(0)', TA specified in the argument
will not be added to the plot object. 'match' is applied instead.
In the original chartSeries that used S4 method, chart.layout is called to
setup layout and margins. Since now chartSeries is a wrapper for
chart_Series, it should be layout-free and only margins are applied.
The last price displayed on chart will change if subset is
specified in chartSeries. However when zoomChart is called
view the subset series, the last price didn't change. The
displayed price should be the price of the last day in the
subset period.
@erichung0404 erichung0404 force-pushed the refactor_chartSeries branch 4 times, most recently from c54564b to 5216c11 Compare August 17, 2016 13:30
Users can now enter TAs' color settings by calling
chartTheme(addTA = list(...)) to create custom theme parameters.

BBands settings in .chart.theme is refactored to coordinate with
addBBands function.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants