Google Charts Line graph displaying only first and last label - google-visualization

I have a line graph and the X-axis comprises of dates. what I want to do is that, my chart should display only the first-date and the last-date on the axis with sufficient gap in between to display the data related to the other dates (but NOT the label)
eg- http://i.stack.imgur.com/ujSRu.png

You need to set the hAxis.ticks option:
hAxis: {
// set the x-axis to show dates at each end, Oct 27 2013 - Nov 18 2013
// with no tick marks or labels in between
ticks: [new Date(2013, 9, 27), new Date(2013, 10, 18)]
}

If you know the exact amount of data entries, you may do:
hAxis: {showTextEvery: 4}

Related

Power BI - Weekly X-Axis without year, but still sorted chronologically

since I started to use Power BI for my weekly reports, I was not able to resolve the following issue.
Most of my charts are on a weekly basis, so for example a chart of the last 13 weeks will have the following weeks as x-axis values: 47, 48, 49, 50, 51, 52, 1, 2, 3, 4, 5, 6, and 7.
The problem in this case is, that if I sort it by week, Power BI will always sort the values like this: 1, 2, 3, 4, 5, 6, 7, 47, 48, 49, 50, 51, 52. This is obviously wrong because week 1 of the following year should be placed after week 52 of the previous year.
So I came to the following solution: I concatenated the year value with the week value, so the values look like this: ..., 202151, 202152, 202201, 202202, ...
This solved at least my sorting issue. The graphs are displayed in the correct chronological order.
But there is one problem with this solution: The six-digit values are just way to huge and it is very hard for the reader to differ between the weeks.
too large markers
I would like to have only the 2-digit week number displayed on the x-axis, but still keep the sorting properly over the change of a year.
I hope someone has solved this. Thank you in advance!
Configure YearWeek as the "sort by column" for WeekNumber, and switch the X-Axis type to "Categorical" on your Bar Chart
or Line Chart
Perhaps you can use small multiples:
Rough steps:
Create a columns chart
In the Axis field place your week number column
In the Values field place your column containing the values
In the Small multiples field place the year column
Format your visual such that the Small multiple grid has 1 row, but multiple columns.

Row Formatting In Power BI

I am having a dataset of multiple products with it's average rating over the months.
I want to ask how can we do row formatting for example: If the rating of a product keeps on increasing, color it with green else if it's decreasing it should have red color.
I want all this to be done in Power BI.
Sample Data:
With this format of the data, you will have to create a measure for each of the columns you want to colorize. Here are the measures (assuming Table is the name of your table):
June background = IF(SUM('Table'[June]) < SUM('Table'[May]), "RED", "GREEN")
July background = IF(SUM('Table'[July]) < SUM('Table'[June]), "RED", "GREEN")
August background = IF(SUM('Table'[August]) < SUM('Table'[July]), "RED", "GREEN")
September background = IF(SUM('Table'[September]) < SUM('Table'[August]), "RED", "GREEN")
Add a table visual to the report with the columns from your sample and for June to September repeat the following. Right click the column in the values pane and select Conditional formatting -> Background color:
This will open a window, where you can select how to determine the formatting and shall it apply it to values only, totals only or both. Select to format it by field value and choose the corresponding measure for the column, like this:
Repeat that for the rest of the columns to get this result:
For more information, take a look at Use conditional formatting in tables article.

How to dynamic filter on Power BI?

How can I make a dynamic filter on a Power BI chart?
I have a MONTH table and it contains these values: 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12. I do not want to display data for months that are bigger than the current month, MONTH(TODAY()).
I want something like this:
You can set up a measure instead to determine whether to show the particular month or not as follows:
Show = IF(FIRSTNONBLANK('Month'[Month], 13) <= MONTH(TODAY()), 1, 0)
And then you can add this measure to Visual level filters and set it equal to 1.
Results:

Invalid format for date labels in graph

I'm only starting with Stata but went through a lot of available pages already to find answer to this.
Using simple dataset with two variables aa and bb.
aa is formatted as %td
bb is formatted as %8.0g
The graph command I've been using is as follows:
graph twoway tsline bb,
title("Numbers by Day", size(medsmall))
ytitle("Value", size(small))
xtitle("Date", size(small))
ysize(2)
xsize(4)
tlabel(#15, labsize(vsmall), format(%tcD_m_CY))
ylabel(#10, labsize(vsmall))
I am trying to format dates as something else rather than 21jan2016
but whatever I put in the format function I get an error "Invalid Date"
%tcD_m_CY is just an example from Stata forum: I tried double quotes and other things and it all fails..
(I did use tsset first to define date axis.)
Your question lacks a minimal, complete, verifiable example in so far as (1) it lacks data we can read in and (2) several details in your example are irrelevant to your problem. See https://stackoverflow.com/help/mcve
Your example shows an argument fed to the format() suboption of tlabel() (not function) which starts %tc: this insists to Stata that values which have been input as daily dates (and counted as # days with an origin 0 = 1 January 1960) are to be interpreted as date-times (and counted as # milliseconds with origin 0 = 01jan1960 00:00:00).
So, by your instruction, a daily date such as 25 July 2016 (which is held as 20660 given that origin) is to be displayed as if it were a date-time. Such a date-time is just about 2 seconds after the start of 1 January 1960; and the rest of your display format D_m_CY says "just show me day, month and year" and the day, month and year are, as said, 1 January 1960 according to this instruction.
I see nothing invalid in your date format so far as Stata is concerned; the problem is human, that it is not at all what you want. Naturally, I can't explain exactly what was wrong with whatever other code you tried and don't show us.
The fake data and code below illustrate some technique. For daily dates, labelling every day is usually a bad idea with more than about a week's worth of data, as you just don't have enough space; similarly showing the same year again and again is usually unnecessary and a poor use of space. An axis title such as "Date" is superfluous so long as dates are clearly given. These points apply whatever software you are using.
clear
set obs 15
gen aa = daily("30 Jun 2016", "DMY") + _n
format aa %td
mat bb = (12, 14, 10, 8, 6, 8, 9, 11, 13, 15, 17, 19, 21, 23, 25)
gen bb = bb[1, _n]
tsset aa
graph twoway tsline bb, ///
title("Numbers by Day") ytitle("Value") xtitle("") ///
tlabel(#7, format(%tdd_M))
It's your graph, but the bottom line is simple: daily dates will need some kind of %td format, and %tc format is utterly wrong, on a par with confusing cents and millions of dollars as units.
You don't say exactly what you read, but this is well documented: help datetime in Stata and whatever it points to are all you need to study.
Note also http://www.statalist.org/forums/help#spelling

Formatting google chart area date( like Mar 2012, Oct 2013 etc)

I want to show Google Chart Area date as Mar 2012, Oct 2013 etc. There should not be any date digits in the format. I can only find 3 formats as
formats
var formatter_long = new google.visualization.DateFormat({formatType: 'long'});
var formatter_medium = new google.visualization.DateFormat({formatType: 'medium'});
var formatter_short = new google.visualization.DateFormat({formatType: 'short'});
Resulting in to
February 28, 2008 (long)
Feb 28, 2008 (medium)
2/28/08 (short)
long and medium work for me if I can remove date digits from the result. Is there a chance to do it somehow?
Google uses a subset of the ICU SimpleDateFormat standard.
If you mean "remove date digits" as in "remove the day and display just month/year" then you could format the string as follows:
function drawVisualization() {
// Create and populate the data table.
var data = new google.visualization.DataTable();
data.addColumn('date', 'Date');
data.addRows([
[new Date(2012,1,5)],
[new Date(2012,2,10)],
[new Date(2012,3,15)],
[new Date(2012,4,20)]
]);
alert(data.getFormattedValue(3,0));
var formatter1 = new google.visualization.DateFormat({pattern: 'yyyy, MMM'});
formatter1.format(data,0);
alert(data.getFormattedValue(3,0));
}
When you define the data table, the first alert will list the formatted date as "May 20, 2012". Once you apply the formatter, it will read "May, 2012" only. I think this is what you want. You can change the format as desired.