How to change position in MPAndroidChart PieChart color indicator - pie-chart

I am working on MPAndroidChart and I want to change position of PieChart color indicator.
<com.github.mikephil.charting.charts.PieChart
android:id="#+id/chart"
android:layout_width="200dp"
android:layout_height="200dp"
android:layout_gravity="center" />
When i set android:layout_width="200dp" and android:layout_height="200dp" It apply height and width whole view.
I want to only make distance between PieChart and its color indicator.
Don't want to overlap indicator on PieChart View

<com.github.mikephil.charting.charts.PieChart
android:id="#+id/chart1"
android:layout_width="match_parent"
android:layout_height="match_parent"/>
Legend l = mChart.getLegend();
l.setPosition(LegendPosition.LEFT_OF_CHART);
l.setXEntrySpace(7f);
l.setYEntrySpace(5f);
l.setYOffset(0f);
OR
Legend l = mChart.getLegend();
l.setPosition(LegendPosition.RIGHT_OF_CHART_CENTER);
l.setXEntrySpace(7f);
l.setYEntrySpace(5f);
l.setYOffset(0f);

You can set position of color indicators like LegendPosition.RIGHT_OF_CHART,LegendPosition.BELOW_CHART_LEFT etc.
Legend l = mChart.getLegend();
l.setPosition(LegendPosition.RIGHT_OF_CHART);
l.setXEntrySpace(7f);
l.setYEntrySpace(5f);

Legend l = mChart.getLegend();
l.setPosition(LegendPosition.RIGHT_OF_CHART;
l.setXEntrySpace(7f);
l.setYEntrySpace(5f);

Related

Style / remove axis overlap indicator in lightningChart js

I would like to style axes in LightningChartJs and are not able to remove the little lines on axis overlap and the end of axis (Please see image below).
To set thickness of axis has no effect on the indicators:
const axisYStyles = axisYColors.map((color) => new SolidFill({ color }));
const axisYStrokeStyles = axisYStyles.map((fillStyle) => new SolidLine({ fillStyle, thickness: 1 }));
const axisX = this.chart.getDefaultAxisX()
.setStrokeStyle(axisYStrokeStyles[0]);
Would be nice if someone can help and explain how to remove or style this items. Thx in advance.
The little lines at the ends of the axis line are called "nibs". You can style and hide the nibs with Axis.setNibStyle().
emptyLine can be used to completely remove the axis and nib lines.
// Axis styling
chart.getDefaultAxisX()
// Hide the main axis line
.setStrokeStyle(emptyLine)
// Hide the Nib at the ends of the axis
.setNibStyle(emptyLine)
// Extract required parts from LightningChartJS.
const {
lightningChart,
emptyLine
} = lcjs
const chart = lightningChart()
.ChartXY()
// Axis styling
chart.getDefaultAxisX()
// Hide the main axis line
.setStrokeStyle(emptyLine)
// Hide the Nib at the ends of the axis
.setNibStyle(emptyLine)
chart.getDefaultAxisY()
// Hide the main axis line
.setStrokeStyle(emptyLine)
// Hide the Nib at the ends of the axis
.setNibStyle(emptyLine)
<script src="https://unpkg.com/#arction/lcjs#1.3.1/dist/lcjs.iife.js"></script>

Outlines around segmented cells

The following lines, creates white rings (outlines) around my segmented cells
se1 = strel('diamond',10); se2 = strel('diamond',4);
R = imdilate([RED],se1)&[~imdilate([RED],se2)];
imshow(R)
And this line displays my segmented cells in RGB form.
r = imadjust(mat2gray(RED));
z = zeros(size(r),'like',r);
r = cat(3,r,z,z);
imshow(r)
Now, with a "hold on;" between two code, the outlines should be plotted around the red cells but it doesn't. I'm trying to plot white outlines around my segmented cells. Thanks for your help.

How do I add a units label to a ILNumerics Colorbar

I would like to display the units in text for the values displayed on the colorbar. I have a colorbar added to my ILSurface and I'd like to show my units in text on the color bar along with the range.
Edit: I want to display text at the bottom of the color bar below the bottom tick just the one label.
I was able to get this to work this way
new ILColorbar()
{
Children = { new ILLabel("nm") {Position = new Vector3(.2f,.98f,0) } }
}
I have to say the Position coordinates are not very intuitive. I had to basically adjust the numbers by trial and error until it fit. I knew that the values range 0..1 so the X value was 1 at the bottom but I wanted it up from the border. And the Y value would need to be indented in some but I wasn't sure what was a good value but .2 works.
You can access the axis of ILColorbar and configure it in the usual way. Use the LabelTransformFunc on the ticks to set your own label text. You can use the default transform func and add your unit string.
Example:
var cb = scene.First<ILColorbar>();
cb.Axis.Ticks.LabelTransformFunc = (ind, val) =>
{
return ILTickCollection.DefaultLabelTransformFunc(ind, val) + "nm";
};
You can read more about the axis configuration here:
Axis Configuration
LabelTransformFunc in ApiDoc
Edit:
If only one label is needed, then add a new ILLabel object in ILColorbar group as follows:
new ILColorbar() {
new ILLabel("z(nm)") {
Position = new Vector3(0.5,1,0),
Anchor = new PointF(0.5f,0)
}
}
The ILColorbar area have the relative coordinates 0..1 over the width and the height of the color bar. So we set position x in the middle of the ILColorbar, and position y at the bottom.
The Anchor position is used as relative position in relation to the Position point.
ILLabel Documentation

Add Margin and Chart header alignment in Jfree charts

Greeting,
I was wondering is it possible to add some margin to Jfree charts and align the chart title to left of the chart rather than default center of the chart.
Expected Chart
Need to add a 28 px margin to all directions. TOP , BOTTOM , LEFT and RIGHT
And to make the chart title align to the left rather than center.
Chart which i am able to generate
To Add margin to Chart we can add Padding
public void addMargin(JFreeChart jChart){
RectangleInsets chartRectangle = new RectangleInsets(28F,30F,30F,30F);
//RectangleInsets chartRectangle = new RectangleInsets(TOP,LEFT,BOTTOM,RIGHT);
jChart.setPadding(chartRectangle);
}
To align the header to Left set horizontal alignment to Chart title
public void alignChartTitle(JFreeChart jChart){
jChart.getTitle().setHorizontalAlignment(HorizontalAlignment.LEFT);
}
Set value to the lowerMargin, upperMargin property of X Axis. This is kotlin code:
val dateAxis = DateAxis("Time")
dateAxis.lowerMargin = 0.05
dateAxis.lowerMargin = 0.05
And this is the result:
[]

How to draw border around the chart area in Google Charts?

I need a border around just the chart area and not the whole chart. I can't find what property to set. This is in the Google Visualization API.
The appropriate option is undocumented. You need to set the chartArea.backgroundColor.stroke and chartArea.backgroundColor.strokeWidth options. The stroke option controls the color of the border, and takes any valid HTML color string. The strokeWidth option controls the width of the border, and takes an integer for the width in pixels:
chartArea: {
backgroundColor: {
stroke: '#4322c0',
strokeWidth: 3
}
}