Opposite and horizontal property for labels in Pie Series - amcharts

I was wondering if there is any way I can show labels Horizontally for PieSeries above Pie Graph, as by default it is shown below graph and vertically. I tried to find a way similar to Opposite property of AxisRendererX as given in OppositeProperty explanation, But I failed to show my labels in a Horizontal way above graph! An image of Pie Series that needs to be updated is attached for your reference.

amcharts uses the full area you provide for a chart. If you set the width of your chart to a small value, you have the result you showed. If you resize your chart like I did in the code pen below, the labels are shown horizontally.
To change the legend position you can use the legend.position attribute.
Available options are: "left", "right", "top", "bottom" (default), and "absolute".
https://www.amcharts.com/docs/v4/concepts/legend/#Positioning
In your case you can use the following code to move the legend to the top:
chart.legend = new am4charts.Legend();
chart.legend.position = 'top';
I created a code pen for your example.

Related

Alignment and Colors of Data Point Outliers of Box Plot

Is it possible to align the data points and outliers of box plot in one straight line like in center of box plot?
Additionally, can I color the data points?
The current and the desired screen shot are attached with it.
You can use
.dataWidthPortion(0)
to not spread the points out at all. Documentation.
General advice on changing the color or style of anything, if there is no accessor for it:
Look for the chart in the chart selectors wiki, or if it's not there, inspect the item you want to change in the developer tools and find out what SVG tag and CSS class the item has. In this case, it's circle.data
Add a pretransition handler which selects the items you want, and changes them:
var cc = d3.scaleOrdinal().range(d3.schemeDark2);
bp02.on('pretransition', chart => {
chart.selectAll('circle.data').attr('fill', function(d) {
const boxDatum = d3.select(this.parentNode).datum();
return cc(boxDatum.value[d]);
})
});
In this case, we're creating an ordinal scale to map the available data to the colors in a color scheme.
The interesting question is here is what data to bind to the color of the dots, and how to get that data.
A box plot's data consists of an array of key/value pairs where each value is a Y value. When the box plot draws it will bind each circle.dot element to the index of the data in the array.
So we need to get the array that is bound to the box. Luckily d3.select(this.parentNode).datum() will give us the key/value pair for the box.
For this example, we are encoding the color based on the Y value, which we get by looking inside boxDatum.value. You don't specify how you want the dots colored but this shows the data that is available.

amcharts Overlay legend on a chart

How can I overlay the legend on a column chart without?
Would I need to use absolute positioning? If so, could someone provide an example?
Please see the picture below.
https://www.amcharts.com/docs/v4/tutorials/chart-legend-in-an-external-container/
I managed this by placing the legend in another container, then setting an absolute property and overlaying the div.
var legendContainer = am4core.create("legenddiv", am4core.Container)
chart.legend.parent = legendContainer;

How to change z-index of amCharts axisGuides

I am trying to visualize a filter in my stock chart by graying out data points which are affected by the filter. I'm using axisGuides on my valueAxis in order to achieve this. However, I also have axisGuides on my categoryAxis and unfortunately, these now disappear beneath my horizontal axisGuides.
Is there any way to change the z-index of those guides? Or does anybody have a different solution?
I have adapted an official amCharts example to show what I mean:
http://jsfiddle.net/wq97ujne/
I'm setting plotAreaFillColors": '#ababab' on my stock panel and fillColor: "#ffffff" on my valueAxisGuide.
I would like for the vertical guides to be drawn in front of and not behind the white area.
You need to set above: true for the categoryAxisGuides.

Tooltips getting cutoff in pie charts in highcharts

I have a pie chart which is being generated from a json string. The pie is getting created correctly but what is happening is the tooltip is getting cutoff when the text to be displayed in the tooltip is large. I have tried increasing the width and height of the svg area. But the charts are generated dynamically so i have no way of setting the chart widht and height dynamically depending on the content.
One can adjust the margins margin:[0,100,0,100], to shrink the pie chart so that the tooltips/labels will appear. This has been set to automatically scale the chart in Highcharts 3.0.
http://www.highcharts.com/component/content/article/2-news/53-highcharts-3-0-beta-released
http://github.highcharts.com/v3.0Beta/highcharts.js
http://jsfiddle.net/Zvrt6/1/
Increase Height and width of your chart div or put your code in jsfiddle if possible, so that we can get more idea
This example could be relevant to your situation- http://jsfiddle.net/4ac8b/1/. When you re-size the result pane you will notice the chart size changes accordingly.
You will need to set the size of your container so that the chart is drawn in that area itself. http://jsfiddle.net/4ac8b/. Even when you re-size the result pane the chart size wont change.
Change the diameter of your pie chart to allow additional information
http://www.highcharts.com/ref/#plotOptions-pie--size

How to Change Legend Type in Excel?

I have a line chart, where the chart legend also in forms of line. Is there a way I can change the legend type from colored line to colored circle or square?
Figure like this. http://www.nevron.com/gallery/FullGalleries/chartActiveX/stackline/images/StackLine1.png
I don't think you can use this method to get circles, but if you want to get squares, you can change the chart to a 3-D line chart, then right-click the chart area and select '3-D Rotation'. Change everything in the Rotation section of the menu to as close to 0 as you can get it. This will make your chart show up as a regular line chart while the legend shows little cubes. After you've done that, though, you'll probably have to change the axis settings. In my experience, 3D charts tend to show too many gridlines.

Resources