How To Pass Dates As Dataset in ChartJS - reactjs

I have created a chart and instead of numbers I want to show dates in xAxis and I want to set the progress of the bar as per the difference of days between two dates, for example on the first column in Week 1 inside W1 I want to show blue bar from 01/02/2022 to 10/02/2022 something like that, is it possible to do in Chart Js? I have attached the stack blitz link as well. Basically, I want to manage it using dates.
StackBlitz Demo

Related

Dropdown menu to control which series to show in a chart

It's the first time I use Google Data Studio and I'd like to add a control (dropdown menu) to my report that allows me to control which series to show in a Combo chart.
1. Data
Data is organized in a (Google Sheets) as shown below:
Year
Safer Buildings (Annual)
Safer Buildings (Cumulative)
Safer People (Annual)
Safer People (Cumulative)
2021
10282
100126
56461
524152
2020
11655
89844
57425
467691
2019
13743
78189
68120
410266
2018
9332
64446
52807
342146
2017
4904
55114
34971
289339
2016
1006
50210
11928
254368
2015
1723
49204
8317
242440
2014
518
47481
2541
234123
2013
7015
46963
34491
231582
2. Expected output table
I'm not sure a different table is needed besides the one provided above.
3. Chart
I created a 'Combo chart' based on the data above, as shown below.
Chart setup:
More specifically, I'd like to add a control (dropdown menu) to my report that allows me to select between two entries 'Safer Buildings' OR 'Safer People' in a way that:
If I select 'Safer Buildings' I will see, in the chart shown in the picture above, the bar chart for 'Safer Buildings (Annual)' (blue) AND the line chart for 'Safer Buildings (Cumulative)' (cyan).
If I select 'Safer People' I will see, in the chart shown in the picture above, the bar chart for 'Safer People (Annual)' (magenta) AND the line chart for 'Safer People (Cumulative)' (orange).
I know I can achieve something similar by switching on 'Optional metrics' but I cannot find a way to implement it with a dropdown menu.
4. Issue/Attempt at solving
In order to achieve what I'd like to do. I tried to simplify the task and to focus, initially, only on 2 metrics 'Safer Buildings (Annual)' (bar chart) and 'Safer People (Annual)' (bar chart).
First of all I created a parameter named 'impact_metrics', defined as follows:
Then, I created a dummy field named 'Impact metrics (dummy)', define as follows:
Finally, I created another field named 'Test1', defined as follows:
I went back to the Combo chart and I modified the setup as shown below:
Now, if I select a different parameter in the 'Parameters' field highlighted by a red rectangle in the picture above, the Combo chart gets updated as expected (see below).
However, now I don't know:
how I can show both the bar chart for 'Safer Buildings (Annual)' AND the line chart for 'Safer Buildings (Cumulative)' when selecting 'Safer Buildings' in the 'Parameters' field highlighted by a red rectangle in the picture above.
If I edit 'Test1' field as follows, I get an error (see below).
how can avoiding having to select a parameter in the Combo chart setup and have instead a dropdown menu to do that.
5. Report
At this link you can find the editable Data Studio report.
Any advice is very welcome! Thank you.

How can I filter based on count within a dimension in a stacked bar chart?

Background
I have a Google Data Studio report showing Google Forms survey results based on different demographics. I need to protect the anonymity of people that responded to the form so I do not want to show the results if fewer than 5 people responded from either an individual demographic category or from a combination of categories.
In my Google Data Studio report I have a stacked bar chart showing the breakdown of how people responded to the question. The chart has a dimension that can be selected from a data control and then it is possible to drill down into the data. I then have 9 separate dropdown list data controls to allow the user to filter by different demographics.
Stacked bar chart from Google Data Studio:
Gender
Hair colour
Eye colour
Question response
Man
Blond
Blue
Man
Brown
Blue
Probably
Man
Black
Brown
Not at all
Man
Blond
Blue
Probably
Man
Brown
Green
Definitely
Man
Black
Brown
Neutral
Man
Blond
Blue
Definitely
Man
Brown
Brown
Probably
Question
How do I apply a filter to the dimension so the dimension does not show if there were fewer than 5 responses for that dimension? I still want it to show the data for the dimension if there were >5 responses for the individual segments of the stacked bar chart
Attempt
I am able to assign null values if there were fewer than 5 respondents from an individual demographic in my data prep. I am also able to ensure the dropdown list data controls do not show categories where there were fewer than 5 responses by applying a filter to each data control. However if I apply the same filter to the chart, it filters out any segment of the stacked bar chart where there were fewer than 5 responses rather than if there were 5 responses to the whole dimension/demographic
Filter configuration:
Resulting bar chart with no data:
Expected output
When Hair colour is selected as 'Blond' only in the data control, the bar chart should show a stacked bar for 'Man' but no stacked bar for 'Woman' as there are fewer than 5 responses for 'Woman'
Sample
Data Set (Google Sheets)
Google Data Studio report
If I select Hair colour = blond from the data control, there are 7 responses from men and 2 from women. I want the responses from men to display but not for women as there were only 2 women with blond hair in our sample which is less than 5. If I apply a filter exclude record count < 5, then it removes men from the chart as well as women because there were fewer than 5 responses for each survey option ('Definitely', 'Probably' etc.).
I managed to solve this using a version of Nimantha's answer to this question: How can I re-categorize any counts < n in Google Data Studio?. I basically wanted to achieve the same thing but on a stacked bar chart and I wanted to remove the redacted responses completely from the chart.
As in Nimantha's answer to the question above, I created a calculated field containing COUNT(Gender) in my main data source. The additional step was I then created a simple bar chart with Gender as the dimension and Count Gender in the metric field. The key was to apply a filter to this chart which excludes that count gender calculated field if the count is less than x (in my case 5).
I then blended that chart with my original chart (both using the same data source) with a left join on Gender. I then re-created the stacked bar chart using the same fields (gender in dimension, question response in breakdown dimension and record count as the metric. This chart inherits the filter from the helper chart to remove the dimension if gender count is less than 5.
I've updated my original sample to show this in action here: https://datastudio.google.com/reporting/4476440c-f322-4087-8d76-013a0d59835c
Click here to view screenshot of working version

How can I create a reference line that adjusts based on drop-down list selection in Google Data Studio?

I have a bunch of key measure graphs, for this example, I will use the Safety key measures.
To add a goal line to a bar graph
I created a parameter called Safety Goal.
My data type is number (decimal),
my permitted values are Any values
my default value is 0.
On the Chart > Bar > Style > Reference Line #1
Type = Parameter
the rest is left to the defaults
Also created a inputbox with control field set as this parameter "Safety Goal"
This works if I type in a number in the input box, I receive my goal line.
How can I set this up to create a goal-line based on a selection in a drop-down list?
The Data Studio Minimal reproducible example can be found at this link
https://datastudio.google.com/reporting/3b476f9a-e79b-4421-b755-a086d9c8e7f5/page/LfniC
The data source link is https://docs.google.com/spreadsheets/d/1RJg16hWB_KfmTuDJAYgyrw_TVIK1LGRKY6qMGDE-5nk/edit#gid=1090568723
This link can be found on the Google Datastudio at the very bottom
chart>bar graph parameter settings:
parameter:
Control>input box settings when this number changes, the ref bar shows at that number which I call our "goal" I want this to work with the drop-down menu called Bay:
If you want to create a list of choice, you can do that if you create a parameter using the list of values and you enter your list of value manually.
If you want to use a list from a datasource and use that selection a the value for the reference line that is not possible within the same chart. You could create another chart, line chart, and show that line in front of your bar chart. But that would require that your Y axis are identical. You won't be able to use the auto Y axis, otherwise your 2 graph might end up with 2 different scale and your ref line will not represent the proper number on the bar chart.
To do this
you need a datasource with your goalline to be a different datasource than the one used in the bar chart. This datasource will contains two rows for each goaline value in the first column. the second column will contain the metric for the line. We want zero and a 1. for example
goaline
horValue
23.5
0
23.5
1
29
0
29
1
You will be filtering your result when you select within the drop down
you need to create your control dropdown list with your goalline datasource and choose goaline for your dimension
make that dropdown single select
create your bar chart and set the min and max for your Y axis
copy your chart and transform it into a line chart
for your dimension, choose horValue
for your metric create field choose goaline
in the style of the chart, for your series #1
for the line thickness choose "none"
hide data label
add a reference line
select type metric and choose goaline,calculation max
remove the legend
untick show axes and resize the chart area with your mouse in order to make sure the graph aligns with the one underneath
the problem with this is that you reference line will block your chart below. If wanted to use the data label card or total card the chart in front will prevent you to use it. You could have your ref chart behind the graph, the ref line chart will be slightly hidden from the bar chart in front.
Otherwise you could also use the area chart behind the bar chart to create the same thing, but I will let you figure this one out
I forgot to turn off the label of the ref line graph.

SSRS 2016 - How to display a chart, based on a condition, in the same page location

I am creating a SSRS Report (PPT export) with multiple charts and fixed number of pages. Each page contains multiple charts. I want to display different charts in the same page location based on a condition.
Now I know that ,we can Hide/Show a chart by specifying an expression for visibility attribute, but this will only Hide/Show the single type of chart in a preassigned location.
Just to reiterate
If Condition1=True
Display Chart1 at location (0,0)
Else
Display Chart2 at location (0,0)
Note: Chart1 and Chart2 are generated from different datasets
Thanks in Advance!
This is very simple to accomplish.
Create both charts and place them on top of each other in the report designer. Set up your visibility settings to only show one based on your criteria and as only one gets rendered, they will not interfere with each other or the rest of the report layout.
I Think position property for Chart is not available, so we can not manage chart position directly with any position parameter. but there is work around. create your all charts (multiple charts) in your report design, position them as you want and change their visible property as per your conditions.
e.g. if Chart1 to be displayed at position1 and position 2 based on condition, there will be 2 charts in your report RDL one at position1 and another at position2. manage each charts visible property as per condition, you should achieve what you need.
this is tried by me earlier.

Limit data based on UniqueCount

I have charts on a tab, that should only show if 1 value from a column filter is selected.
For example if a field named: BUSINESS_UNIT has values of "HR","FIN","IT" The charts should only show data if 1 value is filtered on. Such as "HR."
These charts do not contain the BUSINESS_UNIT field itself.
I tried using the Limit Data Using expression, but for some reason the limit expression UniqueCount(BUSINESS_UNIT)=1 doesn't work.
How would I hide the data in the charts, unless 1 BUSINESS_UNIT is selected?
What you could do is hide the filters panel and create radio buttons on a new text area for each property to mark data. If you need help setting this up let me know. Then in your visualisations limit data using markings and show an empty visualisation if no items are marked.
One downside to this is maintenance, if the values change you will have to update the UI.
Another possible solution (untested) is to change the filter panel properties from checkboxes to radio buttons.
Filter Panel Properties:
http://stn.spotfire.com/spotfire_client_help/filter/filter_panel_properties.htm
You want it to look something like this:
http://stn.spotfire.com/spotfire_client_help/filter/filter_radio_buttons.htm

Resources