amcharts / amstock3

JavaScript Stock Chart V3
Other
53 stars 31 forks source link

Category axis doesnt show all labels #5

Open igoraresti opened 6 years ago

igoraresti commented 6 years ago

Im trying stockchart to evaluate if we should by the license. I have found some issue in this chart and i can't solve it. The category axis is showing few labels and not all even if i have data. My categoryAxesSetting is like this: amChartOptions.categoryAxesSettings = { "axisHeight": 100, "labelRotation": 45, "equalSpacing": true, "minPeriod": "mm", "maxSeries": 0, }; And my categoryAxes for each panel is like this: categoryAxis: { parseDates: true, equalSpacing: true, minPerio": "mm",

                labelFunction: function (valueText, date, categoryAxis) {
                    return formatDateToCurrentCulture(date);
                }
            }

@martynasma @amcharts

amcharts commented 6 years ago

Status of ticket 33368 was changed to Pending by Anthony Piris on Zendesk. (replying here will set ticket's status back to Open until ticket is Closed)

amcharts commented 6 years ago

New comment from Zendesk by Anthony Piris on ticket 33368. (replying here will automatically notify amCharts support agent)

Hi there,

Apologies for the delay.

By default the chart automatically hides labels to improve readability. You can disable this by setting autoGridCount to false and set gridCount equal to the number of data points.

  "categoryAxesSettings": {
    "minPeriod": "mm",
    "autoGridCount": false,
    "equalSpacing": true,
    "gridCount": 1000,
    "labelRotation": 90, //recommended if you have a lot of labels
    "axisHeight": 50  //recommended to avoid overlap with the scrollbar
  },

You might also need to disable maxSeries to truly get every label all at once, but it is probably not a good idea if you have a lot of data as the labels will likely overlap with each other, even when combined with labelRotation. You might be better off letting the data grouping do its thing and let the chart reveal more labels as you zoom in, but YMMV.

Demo: https://codepen.io/team/amcharts/pen/2c8c4641819de65ad26871fcdc424143?editors=0010

Documentation: http://docs.amcharts.com/3/javascriptstockchart/CategoryAxesSettings#autoGridCount http://docs.amcharts.com/3/javascriptstockchart/CategoryAxesSettings#gridCount http://docs.amcharts.com/3/javascriptstockchart/CategoryAxesSettings#labelRotation http://docs.amcharts.com/3/javascriptstockchart/CategoryAxesSettings#axisHeight

I hope this helps.

Best,

Anthony Piris amCharts

igoraresti commented 6 years ago

My data doesnt have regular periods and the chart is grouping de data. This solution doesnt work neither. I have modified the framework adding new parameter into categoryAxis -> "forceToPrintAllLabels":true". The hach i do in the serial.js file. Now works fine. /*HACK INIT*/if (this.chart.categoryAxis.forceToPrintAllLabels) { b.period = this.chart.categoryAxis.minPeriod; b.count = this.data.length; }/*HACK END*/

Bad chart using autoGridCount to false and gridCount X: https://www.dropbox.com/s/ll1c4tfs7tpu48u/Badchart.PNG?dl=0

Good chart using forceToPrintAllLabels: https://www.dropbox.com/s/wxrpbehjir18ezp/GoodChart.PNG?dl=0

amcharts commented 6 years ago

New comment from Zendesk by Anthony Piris on ticket 33368. (replying here will automatically notify amCharts support agent)

Hi there,

I highly recommend against modifying the serial.js file as any updates we release will break your changes.

As I mentioned, data grouping will still hide some labels. You can disable it with maxSeries = 0 if you want but if you have a lot of data they'll likely overlap.

If you could provide a fiddle or codepen that reproduces your situation, we can certainly take a look to see if there's a solution within the current API.

Best,

Anthony Piris amCharts

RamosMicaela commented 6 years ago

Hi there, I'm using amCharts 4 and trying to add a stacked column chart on my web page and using the example just as you guys bring on the package but the labels of my axes are showing in a funny way. The first element label on axes is different than the rest of them. Here's a picture of how it looks.

imagenconsulta

Why is this happening? Can I fix it?