Amcharts column chart labels don't align below column when interval is greater than 1 - charts

Please look into this demo column chart.
https://www.amcharts.com/demos/step-count-chart/
When the date axis interval is 1, the axis label aligns perfectly below the chart.
But when the axis label interval is increased to 3 or above, the label starts appearing between columns instead of below the column.
baseInterval: {
timeUnit: "day",
count: 5
},
Please let me know how to align the labels with an interval other than 1.
Thanks

Related

Put Axis Range label above in am4charts

I have a am4charts (v5) chart with a bars and a line (made with axis range), but i cannot put the axis range label above series line.
I tried with above param, with zIndex, but i cannot make it work.
I put the above param here in the axis range creation
let seriesRangeDataItem = yAxis.makeDataItem({ value: value, endValue: value, above: true});
This code reproduce the problem
https://codepen.io/javierflti/pen/wvxKRWo
As you can see, label "120" is not above bars
Any idea?
Thanks

How to use echarts visualMap to color Line depending on X-Axis Value?

Expected:
I want to divide single line into 2 parts based on x axis value.
Example, when x-value is greater than "2016-8" show dashed line as following
Tried with ECharts visualMap, but it only works depending on y-axis value
https://echarts.apache.org/examples/en/editor.html?c=line-aqi
It seems VisualMap can only be used to change the color and/or symbol of the line.
Different colors on the same line using VisualMap on xAxis
If you don't specifically need to get a dashed line and you just want to use VisualMap on xAxis, you should set visualMap-piecewise.dimension to 0 (0 being x and 1 being y in simple [x,y] series).
visualMap: {
dimension: 0,
},
Then you'll need to set your list of pieces depending on the type of xAxis ('time' or 'category'):
'time' : full example
'category' : full example
Dashed line on half the series
If you specifically need to get this :
when x-value is greater than "2016-8" show dashed line as following
You can split your series in 2 different series and affect a different line style to each of them:
Series 1: date <= "2016-8" (solid line)
Series 2: date >= "2016-8" (dashed line)
Here is a working example.

XAxis entry count is greater than it should be in iOS Charts 3.0.1 in Swift 3

I have two BarChartDataSets. One of them is always size 3 and the other is either 2 or 3. I tested out the code in version 3.0.0 and everything was working fine. When 3.0.1 came out, it broke my chart. I have the correct number of bars always, but I have six labels instead of 5 when the second dataset is only size 2. It has nothing to do with the stringForValue Delegate function. I set the X values using int's that are associated linearly with the Bar I want represented at that index, so each bar is equally spaced when working properly, but none of them are equally spaced when I have 6 labels and 5 bars.
The one on the left shows the issue and the one on the right shows what it looks like when my BarChartDataSet is size 3. It is duplicating whatever the last value on the chart is and adding it as a 6th label on the left. In 3.0.0 the one on the left would have only had 5 labels.
I dug into their code and where they create the labels in XAxisRendererHorizontalBarChart.swift right before they call drawLabel() I callprint("xAxis entries: \(xAxis.entries.count)")which prints xAxis entries: 6to the console even though right before I call let chartData = BarChartData(dataSets: [chartDataSet1, chartDataSet2])I callprint("dataEntries1 count: \(dataEntries1.count),
dataEntries2 count: (dataEntries2.count)")which prints dataEntries1 count: 3, dataEntries2 count: 2
First, xAxis.entries and dataSet.entries are totally different.
xAxis.entries are the values that being displayed on the axis as labels, while dataSet.entries is the value displayed for the data, e.g. the dot value in line chart, or the bar value for bar chart.
for x axis, it calculate the label count by your data entries min/max value. In Chart 3.0, x axis behaves like y axis, so it calculates x axis entries like y axis, please take a look at computeAxisValues() for details.
So xAxis.entries and dataSet.entries don't have to be equal size.
If you want to set the x axis label count same as your bars count, you can call: setLabelCount(5(6), true):
open func setLabelCount(_ count: Int, force: Bool)
{
self.labelCount = count
forceLabelsEnabled = force
}
Note, don't call the labelCount setter as it's different:
/// the number of label entries the axis should have
/// max = 25,
/// min = 2,
/// default = 6,
/// be aware that this number is not fixed and can only be approximated
open var labelCount: Int
{
get
{
return _labelCount
}
set
{
_labelCount = newValue
if _labelCount > 25
{
_labelCount = 25
}
if _labelCount < 2
{
_labelCount = 2
}
forceLabelsEnabled = false
}
}

How can I put xAxis in highcharts starting in the horizontal line when all values are in 0?

If I have a data like this:
data: [0,0,0,0,0,0,0,0,0,0,0,0,0]
this serie starts on the middle but I want what starts really close than the bottom line and not in the middle.Please take a look in this jsfidle http://jsfiddle.net/gh/get/jquery/1.7.2/highslide-software/highcharts.com/tree/master/samples/highcharts/xaxis/tickwidth/ but change data by my example data (data: [0,0,0,0,0,0,0,0,0,0,0,0,0]), I test with min but in this scenario with all values in 0 did not work.
Thanks
I solve with min: 0,minRange: 1 in xAxis
I would do this simply by setting the yAxis min and max.
Example:
http://jsfiddle.net/jlbriggs/bKr74/1/
You can move xAxis down using offset property (offset: Number; The distance in pixels from the plot area to the axis line.):
xAxis: {
tickWidth: 10,
offset: -155
},
See example at jsfiddle

JfreeChart: Stacked Bar Chart and CategoryAxis showing dates

I have created a stacked bar chart in which I show a count on the y axis and dates on the x axis. The problem is that when I have many dates on the x axis it gets very cluttered and impossible to read. I would like to show only some of the dates, e.g one date per week. Is that possible? I am using ChartFactory.createStackedBarChart() to create the chart, and I have the data in a DefaultCategoryDataSet.
Any input is appreciated!
For a CategoryAxis, which is used the for the domain axis in a StackedBarChart, you have considerable flexility with the method setCategoryLabelPositions(). Typical usage is illustrated in the BarChartDemo1 source, shown here.
CategoryAxis domainAxis = plot.getDomainAxis();
domainAxis.setCategoryLabelPositions(
CategoryLabelPositions.createUpRotationLabelPositions(Math.PI / 6.0));
Have you tried overriding the generateLabel methods in the label generator? Something like:
chart.getCategoryPlot().getRenderer().setBaseItemLabelGenerator(
new CategoryItemLabelGenerator() {
public String generateColumnLabel(CategoryDataset dataset, Integer column) {
if(column % 7 == 0)
super.generateColumnLabel(dataset, column)
else
""
}
}
);
I haven't tested the code, but it should only output a label every 7 columns. More info on the label generator is here: http://www.jfree.org/jfreechart/api/javadoc/org/jfree/chart/labels/CategoryItemLabelGenerator.html