X-axis does not show all the labels on google charts - charts

I want to plot the date vs the number graph with react google charts.
I have the array of data and it has 93 entries. I have the data from 2015 to 2022 for every month. Means there will be 12 entries for each year. I have plotted the line graph, and the graph is showing perfectly except the x-axis label only shows the 2020. As I have set the width of 600, i will be difficult to show all the year on X-axis, but I want to show the year at least with 2-3 years gap. for eg. instead of just 2020, it should be 2015, 2017, 2019, 2021.
If I increase the width from 600px to 1000px, then the chart shows all the years but it will break my UI, so increasing the width is not the solution for me. Here is my options object:
const options = {
chart: {
title: "My title",
},
width: 600,
height: 400,
}

Related

Chart.js Align two time scale axis

We are using chart.js lib Version 3.7.1.We have multichart graph with line and bars. Both using time scale on x axis, but one has one month value, while second has one day value.
example:
const dailyAxis = [27-05-2022, 30-05-2022, 31-05-2022, 01-06-2022, ... 07-06-2022];
const monthlyAxis = [31-03-2022, 30-04-2022, 31-05-2022, 30-06-2022];
The problem is, that daily values could start from the middle of the month or one month could have 20 daily values, other could have 30. Is it possible to align two charts, to have first daily point at start of monthly bar and last point at the end of monthly bar, no matter how many daily values we have?

How to initialize iOS Charts to show data points at a specific x-axis range, e.g. last 6 months from today?

I have a question about iOS Charts by Daniel Cohen Gindi here. The figure below shows my full dataset drawn out as a scatter chart. With the x-axis labels going from January to December (let's say 2018), and then again January to December (2019).
The problem is that I don't want to show all data in range, but just in the past six-month range, July-December, as I want the scatter chart view to look like depicted below. (Note: assume the right-most data point is today.)
I want the user to be able to scroll right to see more data points in the past. I've tried this Swift code below but it would "lock" the x-axis to show July-December, and the user can't scroll right to see past data:
#IBOutlet weak var scatterChartView: ScatterChartView!
scatterChartView.xAxis.axisMinimum = 17.5 // + or - 0.5 for padding
scatterChartView.xAxis.axisMaximum = Double(months.count) - 0.5
And then I would try this code below but it would initially show data from the first 6 months, January-June of 2018. However, the user could scroll left to see the later months.
scatterChartView.setVisibleXRangeMaximum(6)
Close but not quite. Is there any way I could show data from the last 6 months upon loading the scatter chart, and have the user scroll right to see past data?
I found the answer!
scatterChartView.moveViewToX(17.5)
Per documentation, moveViewToX(float xValue) – Moves the left side (edge) of the current viewport to the specified x-value. The view port refers to "what is visible on the chart, aim of the view).
Upon chart loading, the viewport is initialized showing the most recent 6 months, and I can scroll right to see past data.

How to hide legend element based on specific year in Tableau

I am pretty new to Tableau and I have a question about hiding a specific element from the legend box in Tableau software. I have legend based on year (2018,2019) and measure values ( which is calculation formula for retrieving the result for the current and previous year) for 2019 year. I would like in my legend box to hide targets for 2018(previous year). If I exclude Target(Budget) 2018 from the legend box, it is excluding the element Cost, 2018. Could someone help me how to solve this ?
enter image description here

Display legends on Category Axis in Bar chart using Jfreechart or iReport

I am creating a Bar chart using JFreeChart/iReport. Consider below example for reference:
Category Axis displays this series: Jan, Feb, Mar, Apr, May
Every group (Eg: Jan) has 2 bars: Allocated, Unallocated.
In JFreechart/iRport it displays "Allocated" and "UnAllocated" in Legend box. But I it to get displayed on Category axis under respective bar. And below this it should display the series i.e. Jan.
Is it possible with Jfreechart/iReport?
Any help on this appreciated.
Thanks.
This can be achieved by using GroupedStackedBarRenderer. Below is the link for reference.
http://jfree.org/jfreechart/api/javadoc/org/jfree/chart/renderer/category/GroupedStackedBarRenderer.html

BIRT: Staggered values on X-Axis in a chart

I have a chart showing a large time period on the X-Axis (about a year or so). The unit is a day, so only a small part of the labels for these values are visible. I checked the "Stagger" checkbox to display them on two lines, but on the second line only values consecutive to the ones on the upper line are displayed. Thus the distances between the dates displayed are very uneven. For example:
Upper line: May 1, 2010
Lower line: May 2, 2010
Upper line: June 10, 2010
Lower line: June 11, 2010
Upper line: July 20, 2010
I want the distance between them to be more even:
Upper line: May 1, 2010
Lower line: May 20, 2010
Upper line: June 10, 2010
Lower line: June 30, 2010
Upper line: July 20, 2010
Is there any way I can do that?
In Edit Chart window, X-Axis section click on Scale button and specify a step interval or a fixed number of steps.
I couldn't test it, give it a try and good luck!
If this options are disabled try setting the Type field to "DateTime" (or something that isn't "Text") and unchecking "Is Cathegory Axis". This should enable Scale options.