Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

When do you introduce zooming for xaxis.type = 'category'? #1195

Closed
michaeljakob opened this issue Jan 8, 2020 · 11 comments
Closed

When do you introduce zooming for xaxis.type = 'category'? #1195

michaeljakob opened this issue Jan 8, 2020 · 11 comments

Comments

@michaeljakob
Copy link

Is your feature request related to a problem? Please describe.
It has been clear that one of the biggest problems of apexcharts is that 'category' type charts are not zoomable. - and I know of more than 10 users that dropped it for that reason and we are on the verge of dropping it completely and never look back.

We need all the critical features that come with 'category' type charts:

  • tickPlacement: 'on' (instead of default 'between')
  • show the year for all items on the x-axis, not just every 5th year

Describe the solution you'd like
Enable zooming for xaxis.type='category' charts.

Additional context
Our current solution is a 'datetime' with hundreds of hacks, and it still looks buggy. We will definitely drop apexcharts in the next weeks if we can't solve this, which makes us really sad.

I'm attaching two screenshots that illustrate problems with 'datetime'.
We have a financial charts and want to show annual data for each year, e.g. 2018, 2019, 2020

  1. Problem IE11 not working #1: Data should be ON the tick, not somewhere randomly inbetween -- looks buggy
  2. Problem Feature Request: Download to XLSX, PNG and PDF  #2: Show EVERY year, not randomly every nth year -- huge bummer for our users

截屏2020-01-0821 12 45

  1. Problem 3: Again, show EVERY year, especially the most recent year (2019)

截屏2020-01-0821 12 50

How are your plans/roadmap for resolving this major issue?

@michaeljakob
Copy link
Author

michaeljakob commented Jan 8, 2020

I want to highlight how some other parts of 'datetime' are severely broken.
Again: using xaxis.type='category' is exactly what we're looking for and solves all issues at once. The only downside is: we can't zoom!

  1. Critical Problem Could you add the first gauge chart in README to the demo page? #4: Hovering on year 2016 shows tooltip for 2016. Hovering on year 2010 shows tooltip for 2011.
  2. Problem Feature Request : Radar Chart  #5: Note how the x-axis elements are 'off by one'. For year 2000, it seems to be totally lost on the left. The x-axis labels don't align at all with the data.

截屏2020-01-0821 18 57

截屏2020-01-0821 18 48

@junedchhipa
Copy link
Contributor

junedchhipa commented Jan 8, 2020

Hi @michaeljakob
The timescale generation on ApexCharts is basically done this way.

  1. Grab the min X data-point
  2. Grab the max X data-point
    Depending on how much the interval is between the min and max, the ticks are generated in this way.
    Yearscale - The first day and first month (01 Jan) becomes the tick for the year-scale
    Monthscale - The first day and the 15th of every month are generated for month-scale
    Dayscale - Depending on how many days can fit, ticks are generated for day-scale and similarly, hour scale is generated.

I spent last week to allow zooming in the category axis and faced some issues, but most of them will be resolved soon.

Here is what's coming in the next release (hopefully tonight or tomorrow once I test it enough)

  • Zooming will be enabled by default for line charts even in the category axis.
  • For bar charts, zooming will be disabled by default but can be enabled easily by changing 2 properties
    xaxis.tickPlacement: 'on' and chart.zoom.enabled: 'true'. Also, there are some issues with multiple series in a bar chart that part of the bars gets cropped when xaxis.tickPlacement is 'on'. So, you will need to adjust the grid.padding.left and grid.padding.right if this happens.

Screen Shot 2020-01-08 at 7 09 14 PM

The reason why I want to disable zooming for bar charts by default is to prevent a breaking change.
I will document all these things on the website after the release so there is no confusion left.

Thanks for your patience.

@junedchhipa
Copy link
Contributor

Here's a GIF. You can see the bars get cropped in the zooming. I haven't been able to find a good solution for it yet, but some manual workarounds should make it work.
cat-zoom

@michaeljakob
Copy link
Author

Hi Juned,
wow, I'm honestly amazed by the response speed. Your example with revenue/net profit/free cashflow is pretty much exactly what we are building. The GIF looks perfect to me, I'm confident I can fix the right padding/left padding you bring up.
All the other aspects of ApexChart are really great, looking forward to the upcoming release!

@michaeljakob
Copy link
Author

michaeljakob commented Jan 12, 2020 via email

@junedchhipa
Copy link
Contributor

Hi Michael,
You will have to update the core apexcharts version to 3.14.0 from npm - https://www.npmjs.com/package/apexcharts

npm install apexcharts --save

For bar charts, you will have to manually enable zooming

chart: {
  zoom: {
    enabled: true
  }
},
xaxis: {
  tickPlacement: 'on'
}

Unfortunately, the zooming is still not perfect and I am still working on the margin/padding issues. Once it is done, I will close this thread and update it here.

@michaeljakob
Copy link
Author

michaeljakob commented Jan 12, 2020 via email

@junedchhipa
Copy link
Contributor

junedchhipa commented Jan 12, 2020 via email

@junedchhipa
Copy link
Contributor

@Eskimo111
Copy link

Eskimo111 commented Feb 1, 2023

Hi @junedchhipa
I noticed that the columns resize when you zoom in on the gif you previously uploaded; is there any way I can replicate that effect?
I've tried a lot of things, such as switching the version and redrawing the chart on zoom or pan, but nothing seems to work.

@emailnikola
Copy link

@Eskimo111 Columns resize when x-axis is "timeline" instead of "category".

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants