How can I display fewer labels on the X-axis when it is an instance of CategoryAxis? (JFreeChart library) - jfreechart

I have a CategoryAxis used with a BarChart where I have too many labels to be readable.
I would like to set a visible interval for the labels, so let's say each ten values the label is printed.
I read some posts where setTickUnit() method is recommended, but such method doesn't exist in CategoryAxis.
Here you can see a sample of what I am referring to, as you see I have tens of dates so you can't read them:
Any pointer or recommendation?
Thanks!

You can find a pretty good explanation of the problem (and some solutions) in the FAQ section of the JFreeChart homepage.
You might be better of with an XYPlot and an XYBarRenderer.

Related

Drawing a bar chart in the background of candlestick chart in apexchart

I am playing with candlestick graphs (example from here: https://apexcharts.com/javascript-chart-demos/candlestick-charts/basic/) everything work as expected.
However, I am struggling with adding my signal data for a visual representation of the graph.
I am unable to find a solution that works I was thinking I can somehow fine-tune a timeline - I tried chart.js/apexcharts and for now, I believe the closest will be with the second framework.
What I need is a bar chart that can be used in numeric ranges for the X and Y-axis as presented below. (the goal is to be able to add the green bar as presented)
Is there an easy win or an idea of how to approach this?
Is there something I am missing?
That is my current solution (line graphs with stopWin/stopLose and entry price).
Still suboptimal - but works and is easy to achieve.
After weeks of playing around with it - the solution stayed:
I got two instances of apexcharts one with candlestick and one with line graphs
they are in a single div with CSS playground and position absolute.
I am passing standardised min/max values and has to have the same amount of elements in them (line graphs are allowing You to add null values which allow using this solution.
The final version work is repeatable and looks good.
if you need some help in similar case - feel free to reach out ;)

Initialize JFreeChart range axis values

I am trying to load dataset during initialization of the JFreeChart. But every time I tried to create a dataset with higher "number of item per series", the more data (all data) displayed visible in the chart (the bigger the dataset, the smaller the graph). But actually what I wanted is to have the fixed range of dataset values displayed on the chart while the rest is still hidden. Just the same way the data would normally be displayed in the actual trading platform, let's say Metatrader (MT4). First time when I open the chart I can see the screen filled with the only visible dataset of the chart and if I left-scroll the chart I will be able to see the old/history dataset as well. Does anyone have idea how to achieve this using JFreechart?
Really appreciate for any help or any thing/articles I can refer. Thanks so much!
You can use setRange() on either the domain or range axis, as shown in this fragment. If you've already tried this, it may help to edit your question to include an sscce and/or image that exhibits any problems you encountered.

Display percentage value as a fill in a custom shape

I'm looking at some new options for displaying a percentage value as a fill in a custom shape. Consider the effect to be similar to a "progress thermometer" in a traditional dashboard UI sense.
Considerations
Goal - a graphic element showing a percentage value for a custom report.
Format - Either a full graphic (or infographic) itself, or part of a PDF via Photoshop/InDesign or even iBooks (as an excuse to use it).
Usage - I'd like the process to be programmatic, for re-use. It needs to be accurate, and I'd like the solution to be somewhat object oriented to apply to other datasets and graphical containers. This rules out hand-drawn charting.
Source data - currently a pivot table in Excel, but I can work with any other host as required.
Shape - is a custom vector shape that will originate from Illustrator/Inkscape. final format as best fits resolution and rendering of the report. I would also be interested in any other generative shape ideas (such as java/javascript).
Fill - I'd like to be able to represent the fill as both an actual percentage of total area (true up), and as a percentage of the vertical scale. I'd imagine this flexibility would also help reuse of the method as a fill value against selected object variables (height, area, whatever).
I know I'm being slightly vague in the programming languages or hosts side of things, but this gives me an opportunity to break out of the usual analytic toolchain and scope out some innovative or new solutions. I'm specifically interested in open source solutions, but I'm very keen to review other current methods you might suggest.
This might be a little open ended for you, but d3.js is very powerful. There might be some useful templates on the site, or you can build your own from the library.
If you limit yourself to shapes where the percentage can be easily converted into a new shape by varying one of the dimensions, then the display part can be covered by creating a second shape based on the first one, and filling in 100% of the second shape.
This obviously works best with simple shapes like squares, rectangles, circles, etc, where it is simple to convert "50% of the area" or "75% of the height" into manipulation of vector nodes.
However, things gets significantly more difficult if you want to support genuinely arbitrary custom shapes. One way to handle that would be to break up a complex "progress bar" into "progress pieces" (e.g. a thermometer bulb that represents 10% of total progress, then a simple bar for the remaining 90%).
As has been mentioned, D3 seems like it would meet your needs - here are some simple examples of what I think you are asking:
Changing the fill color of a distinct shape: http://jsfiddle.net/jsl6906/YCMb8/
Changing the 'fill amount' of a simple shape: http://jsfiddle.net/jsl6906/YCMb8/1/

Interrupted line/error mark in Dynamic Data Display Chart

I'm using Dynamic Data Display, for line chart (in WPF). I would like to interrupt the line, and display some "Error" label in that point (or on the X axis). Can somebody help me ?
Thank you.
You might use a DataPoint template selector for your datapoint in lineseries, when datapoint values are matching some errors criteria you can apply a different template to the datapoint and show an error label.
The way that I would approach this, is I would add a marker to your line graph every time this "error" occurred along your axes. If you wanted, you could make the tooltip for the marker say "error" or, even better, you could display some information about that error in the tooltip. You can use one of the markers already made in D3, or it's quite easy to create your own!
If you down load the source from Dynamic Data Display, there's many examples that have a similar requirement to yours that you could base your solution off of.

Display percentage on piechart in WPF

Hii
Can anyone tell me how can I show percentage on the piechart....
The percentage is seen on mouseover event but I dont know how to show
the percentage on the piechart's slices....
If you are looking to put labels on the chart itself (instead of tooltip), take a look at this great blog post by WPF guru Bea Stollnitz.
It shows how to do this, in many different modes, and explains not only how, but why.
Take a look at amCharts Bundle for WPF. Pie chart supports labels on the slices, outside connected labels and includes an algorithm to prevent label overlapping.
I've just followed this tutorial (just to make sure) and I get the percentages of each slice as tooltip on mouse over by default.
If you post your code we might be able to spot if there's a problem with it.
You can use labelFunction in mx:PieSeries, and lableFunction look like that
private function pieSeries_labelFunc(item:Object, field:String, index:Number, percentValue:Number):String
{
return StringUtil.substitute("{0} ({1}%)",item.description,percentValue.toFixed(1));
}
Where description is the label that you want to see.
feel free to ask any question.

Resources