Dygraph issue showing Oct-17 on the x-axis - axis

Does Dygraph have any problem with showing Oct-17 month on the X-axis? I have the xts object named L, generated as below:
L1 <- xts(x=1,order.by = as.Date("2017-09-01"))
L2 <- xts(x=4,order.by = as.Date("2017-10-01"))
L=rbind(L1,L2)
Now, if you run
Dygraph (L)
You'll see that Oct-17 is replaced with Sep-17 in the output plot.
Does anyone have any idea why it happened? It's fine with any other month.

This is a common issue with end values. In this case you have created the object L with two dates: "2017-09-01", "2017-10-01". The value Oct-17 has not been replaced with Sep-17 as your final value is October 1st and Oct-17 would be after your actual end date.
In this case the October label on xaxis is hidden and can be shown by simply using rangePad which specifies the amount of extra space (in pixels) around the value range to ensure points at the edges remain visible.
dygraph(L) %>%
dyAxis("x", rangePad= 4)
I have also used a package: dyplyr to be able to use %>% (a.k.a: pipe) operator in R.

Related

How to set name on X axis Using charts on Swift 4?

This is my inquiry (edited):
I try to plot a monthly graphic using Charts, but I face some difficulties to put the names of the months on the X axis. My default value is like in the next image:
default value
And after using the most upvoted answer from here, I got this
So after investing some hours with futile results I'd like to ask you if you know how to get a plot similar to this one, please. So to summarize:
Put the names of the months on the x axis (Vertical, not horizontal as in the figure)
Plot the months' names on the base of the graphic, not on the top as seen on the default value
Thanks in advance. If you need some of my code, I can share it with you.
Kind regards.
After playing around and with a better research, this is the answer to my questions:
//Give the value of the months to the x axis
barChart.xAxis.valueFormatter = IndexAxisValueFormatter(values:months)
barChart.xAxis.granularity = 1
//Position of the x axis, rotation of the labels on the x axis and show all the names of the months consecutively
barChart.xAxis.labelPosition = XAxis.LabelPosition.bottom
barChart.xAxis.labelRotationAngle = -90.0
barChart.xAxis.setLabelCount(counter, force: false)

Bokeh - How to properly set & control xaxis for datetime - possible bug?

I am trying to make a basic line & point plot in Bokeh (0.12.3) using the following code. I have set the x_axis_type as 'datetime' and I am plotting a (random) variable vs. a pandas (0.19.0) datetime64 dtype that is the index of the dataframe (i.e. a timeseries).
The problem I see with the plot is that the dates are not properly aligned. In the time series, the max date is 2016-11-06, however, the last scale tick is for Nov 16, and there is a point aligned to what appears to be several days after that.
Curiously, when zooming in the plot, the alignment looks correct!
Is this a bug, or am I doing something wrong for this plot? Do I need to be more specific in how the x-axis should be rendered?
Also, I really think the scale increments should be in equal number of days. However in this case, Bokeh plots the scale increments to be on the same day of esch month (which is a varying number of days increments). I have seen this before in other plots, and that default can hamper interpretation.
Appreciate any help on this. Here is the code and the screen shots that demonstrate the issue:
# imports & config
import pandas as pd
import numpy as np
from bokeh.plotting import figure, show, output_notebook
output_notebook()
# create a times series dataframe
rng = pd.date_range('2016-07-24', periods=16, freq='W')
df = pd.DataFrame(np.random.randn(len(rng)), index = rng, columns=['Y'])
# view the tail of the data to compare to plot
df.tail()
# make and render the plot
p1 = figure(x_axis_type='datetime',
title='Y vs Week Ending',
plot_width=700, plot_height=400)
p1.xaxis.axis_label = 'Week Ending'
p1.yaxis.axis_label = 'Y'
p1.line(df.index, df['Y'])
p1.circle(df.index, df['Y'])
p1.yaxis.minor_tick_line_alpha=0
show(p1)
the last scale tick is for Nov 16, and there is a point aligned to what appears to be several days after that.
That tick is for Nov 2016.. it's not very intuitive, but the year is contracted into the label.
Knowing this may change your perspective w.r.t. this comment:
...I really think the scale increments should be in equal number of days. However in this case, Bokeh plots the scale increments to be on the same day of [each] month...
What it's done is change the base unit from day to month, which is probably the more correct approach.

kendo chart bar type series combined with line type series the chart reverts to a column type series

I'm trying to add a line type series i.e. "series.Line(s=>s.Name("goal")" to a chart -- this is being used to show a threshold of sorts. The remaining series are bar types series: "series.Bar(s=s.Name("Rate1") and "series.Bar(s=s.Name("Rate2") and "series.Bar(s=s.Name("Rate3") and so forth. If I remove the "goal" line code then the chart renders as horizontal bars as expected; however, if I include the "goal" line code then the chart renders as vertical columns (the default I assume). Any suggestions?
I think you're missing understanding something here.
A line will travel from left to right showing (normally) the progression of a value (normally over a period of time). meaning that their zero value with be on the horizontal axis.
The Bars have a zero value on the Vertical axis.
Therefore the 2 series types are incompatible. Therefore, Kendo changes the chart from "Bar" to "Column".
So basically, what you're looking for is a Vertical Line series type (which I don't think exists).
You may want to look at showing these as Bullet charts instead.
http://demos.kendoui.com/dataviz/bullet-charts/index.html
According to Telerik:
The chart item does not provide built-in support for Pareto chart, in
other words the chart item would not be able to make the percent
calculations for you and you should take care of that prior to binding
the chart. When this is done you can achieve the same functionality by
combining Bar and Line series types. To create a second Yaxis
marked from 0% to 100% try the following code snippet:
chart1.PlotArea.YAxis.AutoScale = False
chart1.PlotArea.YAxis.AddRange(0, 100, 10)
chart1.PlotArea.YAxis.Appearance.ValueFormat = ChartValueFormat.Percent
Here's an example of how to calculate percentages in advance using MySQL:
SELECT a.`Year`, #count := (a.`count`) AS `Count`,
#total := ROUND((#count)/(SELECT #total := count(`year`) AS `total` FROM `table` c) * 100, 2) as `% of Total`,
#cumulative := (#total + #cumulative) as `Cumulative %`
FROM (SELECT #cumulative := 0, `year`,count(`year`) AS `count` FROM `table` `data` GROUP BY `year` ORDER BY `count` DESC) a
ORDER BY `Count` DESC;

How to set my column at the center of the chart with ShinobiCharts

I have this column chart that has 2 modes, monthly visualization and yearly visualization, the monthly visualization works just fine with many column, however, my yearly visualization is broken because i can't get the only column that appears to be on the center of the chart, it's always being set to the first point on my XAxis.
If I were using a NumberAxis it would be easy to solve, just set the column to the middle point (in this case, position 6 among the total of 12 months). However I'm using CategoryAxis, since it isn't ordered as NumberAxis is, I'm unable to use the same solution....
How can I achieve this result with a CategoryAxis ?
PS: No matter the SChartRange I set to this Axis, the column will always be set to the first position in the XAxis.
Found a way to achieve the result I wanted.
I've altered the range to be around the first dataPoint only, this way the column got placed in the middle of the chart without having to be the "middle dataPoint", being the ONLY dataPoint. The code goes into my sChart: dataPointAtIndex forSeriesAtIndex as follows
-(id<SChartData>)sChart:(ShinobiChart *)chart dataPointAtIndex:(int)dataIndex forSeriesAtIndex:(int)seriesIndex{
.
.
.
SChartNumberRange * numberRange;
if(isYearlyChart){
numberRange = [[SChartNumberRange alloc] initWithMinimum:[NSNumber numberWithFloat:-0.9]andMaximum:[NSNumber numberWithInt:(1)]];
}
The normal NumberRange I was using was from 1 through 13.
Hope this helps others with similar problems regarding this subject :)
PS: I'll mark this as the correct answer as soon as possible.

SSRS:How to Add a Trend Line Series to Chart which has only 1 Point on X Axis

The reason I need this is,my chart is inside a Tablix and Only 1 Value(X-axis point) gets supplied to each Row
I can see this line which is centered to chart(as per X-axis) .I want it to run from (X,Y)(0,0) till end of Chart
Pavan,
The trend line is the result of a linear regression and, as such, will need more than one observation in order to be calculated.
For a cloud of data to define the line that represents its trend (a trend line must be unique, that is why I refer to it as "the" trend line, and not "a" trend line), it is necessary that there are, at least, two points in it. With one point you can draw an infinite number of lines - no unique solution.
Anyway, if you want simply a line - and not specifilcally the trend line - you can add a series to your graph with a given number of repetitions of your single value.
Hope this helped...
Julio
Julio,Thanks. I had same thought, so took a step back and got around the problem using Stripline property on vertical axis