PrimeReact - Combo Chart - Need frozen y-axis when scrolling

UI Components for React
Post Reply
karkara
Posts: 3
Joined: 18 May 2023, 01:26

14 Jun 2023, 18:52

Hello,
I have developed a screen using Combo chart(prime react component) and TableContent(Company owned component), which I have defined in Dialog box(Prime react component).

The requirement is when scrolling the dialog box horizontally, the y-axis values should be constant for Combo chart only. Are there any pre-defined methods in chart.js which keeps the y-axis constant or any other approach, please suggest.

Thanks,
Ravi

Primezone45
Posts: 2
Joined: 21 Jun 2023, 10:52

21 Jun 2023, 10:55

In Chart.js, there is no pre-defined method to keep the y-axis values constant while scrolling horizontally. However, you can achieve this behavior by customizing the chart options and implementing some additional logic.

One approach is to use the scales option in the chart configuration to specify fixed minimum and maximum values for the y-axis. By setting these values, the y-axis will remain constant even when scrolling horizontally. Here's an example:

const options = {
scales: {
y: {
min: 0, // set your desired minimum value
max: 100, // set your desired maximum value
},
},
};

You can adjust the min and max values based on your data and requirements.

Additionally, you may need to handle the scroll event of the dialog box and update the chart options dynamically to ensure the y-axis values remain constant. You can listen to the scroll event and update the min and max values accordingly.

Another approach is to use a separate div element to display the y-axis labels and keep it fixed while scrolling horizontally. You can position this div element next to the dialog box and synchronize its scroll behavior with the chart area. This way, the y-axis labels will always remain visible even during horizontal scrolling.

Implementing these approaches will require some custom code and integration with the PrimeReact components you mentioned. It's important to refer to the Chart.js documentation and PrimeReact documentation for further details on chart customization and component integration.

Remember to consult the documentation and explore the available options to tailor the behavior of the Combo chart component according to your specific requirements.

Primezone45
Posts: 2
Joined: 21 Jun 2023, 10:52

22 Jun 2023, 06:36

To achieve the desired behavior of keeping the y-axis constant while scrolling horizontally in a PrimeReact Combo chart, you would need to explore the capabilities and options provided by the PrimeReact Combo chart component itself. PrimeReact may have specific features or configurations that can help achieve the desired effect.

I recommend consulting the PrimeReact documentation, specifically the documentation for the Combo chart component, for information on any pre-defined methods or options that may allow you to keep the y-axis constant while scrolling horizontally. The documentation should provide detailed guidance on how to customize the behavior of the chart component to suit your needs.

If you have further questions or encounter any specific issues during the implementation with PrimeReact, please feel free to ask, and I'll do my best to assist you. MyMileStoneCard

Post Reply

Return to “PrimeReact”

  • Information
  • Who is online

    Users browsing this forum: No registered users and 1 guest