-
Notifications
You must be signed in to change notification settings - Fork 19.7k
[Bug] BAR Chart with Log Axis enabled, seems to perform log transformation on the DataSet Itself and therefore Renders incorrect chart. #20868
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
Comments
replace min with startValue |
@helgasoft Thank you so much for the reply. I just tried this and here're the results.
|
FYI. Just found this JSFiddle Link for HighCharts which showcases, Log Axis with Negative values. Can we take any inspiration from here? May be add something like this as part of the ECharts Library?
|
@tuhinkarmakar3882, good of you to investigate this. I am unable to respond to all of your questions, but negative values has been a long-standing feature request #17459, #15558. Got inspired to hack a workaround - Demo. It works for scatter and bar series, but not for line (and log line crossing zero does not make much sense anyway). |
@helgasoft Interesting finding! Let's hope for the that the changes gets merged. Until then, we'll have to use such workaround. The example code that you provided, uses ECharts to render a dual-grid logarithmic bar chart that distinguishes positive and negative values. It first imports the ECharts library, selects an HTML element with the id "main," and initializes the chart instance. A set of sample data and category labels is defined. A helper function computes the closest power of 10 for each data point to determine a suitable starting value for the logarithmic y-axes. The data is then split into two arrays: one for positive values and one for negative values (converted to their absolute values for proper logarithmic scaling). The configuration defines two grids and matching axes. The top grid (with a hidden x-axis) displays positive values using a standard logarithmic scale, while the bottom grid displays negative values on an inverted logarithmic scale with custom tooltips and labels that prepend a minus sign. Finally, the chart is rendered by applying this configuration to the initialized ECharts instance. |
Version
5.6.0
Link to Minimal Reproduction
https://echarts.apache.org/examples/en/editor.html?c=bar-simple&code=PYBwLglsB2AEC8sDeAoWtJgDYFMBcya6GOAHmAQOQBqOATpAMYCGWsAQs3bAMIAWXMLADuEMH1gAZYAHNYAZRa5KAGiLowZMPLABPXAVTFiAMxjaIAL3ywATAAZ1sAL5FnajcGBZIIQ07A6CBkZeipmUggAZ1UnCOiABWAIaE06f2MNXRAbSiiBABNgYUonV3R3IhkggoziXBMKWEoAZgBSWOMgmT4mygAWDo9iACNgMDBgAFsqds7iRnNmFMlmEZwsAkCAVxw3YdIAQUiouqycqhZNGWA6XXn0AuYwZgIAbUoeZ5wbu9hD1TNL7XW66DiAz7fX5gngQ4E_UGwAAilAAusN0NBmFNcvDfhAcDEMbAsTjpFcoNAqFMIAUCspiaScABxZh-WAtACsxPiUVW602hEysDMqXkVhsAEZ-mV9kRdMdomcMNlclhZA8SdjctRWLsorAABTquRRJQ4ACUmqZ5OelOptPpOGt2tZ7M59mJNKpsHsADp7IHJTyTvyNsr0KKLNYCJLbLKKsMovQCadYG8nEZMkyqPIU4TYJLNedciMuMXYE8Xu9_UGVL6A8GG03JeinOgxDgpjp9DYs8LFur0s0AMS2EwAdhwBQAHBX0GM6AV6AAlZgFCDbNNvbmwXee32o9suYnoLBrcNC4WwfLFLZ0Xan4ggYBRMT25qTEClYXlYh_o9nAAbiAA
Steps to Reproduce
As you can see in the example, the dataset contains
data: [0.001, 0.01, 0.1, 1]
.I tried the same thing with
HighCharts
and there it seems to work fine.Below is a sample HTML code to show highcharts & Echarts together to prove the point and issue:
Current Behavior
As you can see in the example, the dataset contains
data: [0.001, 0.01, 0.1, 1]
.Expected Behavior
As you can see in the example, the dataset contains
data: [0.001, 0.01, 0.1, 1]
.Environment
Any additional comments?
No response
The text was updated successfully, but these errors were encountered: