AnyChart / AnyChart-Android

AnyChart Android Chart is an amazing data visualization library for easily creating interactive charts in Android apps. It runs on API 19+ (Android 4.4) and features dozens of built-in chart types.
2.29k stars 370 forks source link

tooltip format round value #192

Open zeylevruntime opened 3 years ago

zeylevruntime commented 3 years ago

hello, please help me i have code like this L2.tooltip().format("function() {" +"return 'Payment : ' + anychart.format.number(this.value * "+divider+")" +"}"); this code produce tooltip below

tanya

how to make round from tooltip value and formating with group separator? so i can get output rounded integer value like below

"Total : 5.562" ">120 : 494" "91-120 : 207" "61-90 : 779" "31-60 : 1.843" "Sell out : 3.631" "Payment : 1.649"

Shestac92 commented 3 years ago

@zeylevruntime For this purpose, you can use formatting parameters in a string token. Below is the snippet code:

        Cartesian cartesian = AnyChart.area();

        List<DataEntry> seriesData = new ArrayList<>();
        seriesData.add(new ValueDataEntry("A", 51234.23412));
        seriesData.add(new ValueDataEntry("B", 42342.242));
        seriesData.add(new ValueDataEntry("C", 32343.243234));
        seriesData.add(new ValueDataEntry("D", 4.42342));

        final Area series1 = cartesian.area(seriesData);

        cartesian.tooltip().format("{%value}{decimalsCount: 0, groupsSeparator:.}");

        anyChartView.setChart(cartesian);

Below is the result: Screenshot 2020-09-14 at 10 59 33

zeylevruntime commented 3 years ago

oke, its work , thanks.. if you wish I ask another question? how to make area chart starting value from -(minus) like HiLo chart

Shestac92 commented 3 years ago

@zeylevruntime Do you want to apply low and high values to the area? Make it a range-area?

zeylevruntime commented 3 years ago

sW5XX

this is example in excel,area chart starting value can be <0, how to make area chart like this?

Shestac92 commented 3 years ago

@zeylevruntime The chart adjusts the yScale minimum automatically if the data includes negative values. Anyway, you can apply the yScale negative minimum manually. Like this:

chart.yScale().minimum(-2000);