In Highcharts
chart: { renderTo: 'container', width: myWidth, height:350, spacingLeft:-65 },
yAxis: [{ // Primary yAxis tickPositions: [145.00, 150.00, 155.00, 160.00, 165.00], max: 163.50, labels: { formatter: function() { //我想在这里对this.value做判断, 设置chart里的width值 return this.value.toFixed(2); }, }],
Go to the next Highcharts manual to read the document development. There are examples in it
No,
you still make the judgment outside.
After the judgment is completed, set the parameters.
Perform data analysis before loading data, calculate your myWidth and then generate the chart.
This is also the standard idea of this kind of static drawing: that is, the performance is determined by data; rather than during execution During the performance rendering process, change other performance parameters
Perform data analysis before loading the data, calculate your myWidth and then generate the chart.
This is also the standard idea for this kind of static rendering. : That is, the performance is determined by data; instead of changing other performance parameters during the performance rendering process
This was done before, but there is a lot of data, and the performance is not very good now. It takes seven seconds to load Left and right.
No,
you still make the judgment outside.
After the judgment is completed, set the parameters.
I have done the data retrieval, but it is slower
7 seconds refers to the chart drawing time, right? It is impossible to perform data processing and it will take 7 seconds!
If It’s the drawing time: your dynamic changes will further reduce performance. You can only find a way to perform step-by-step loading and other processing to ensure that the browser will not get stuck due to too long execution of js code
If It’s the data processing time: If there is no problem with your algorithm logic, it can only be said that the amount of data is indeed too large. The only way to optimize is to load the data step by step
7 seconds refers to the drawing time of the chart, right? It is impossible to perform data processing and it will take 7 seconds!
If it is the drawing time: Your dynamic changes will reduce the performance even more. The only way is to find a way to perform processing such as step loading to ensure that the browser does not It will freeze due to too long execution time of js code
If it is data processing time: If there is no problem with your algorithm logic, it can only be said that the amount of data is indeed too large. The only way to optimize is to load in steps The data
It is still very fast under IE9, but IE8 is very slow. There are too many data checks, how to solve this situation?
General optimization algorithm ideas: reduce the number of traversals (try to only do one traversal), do not use iteration/recursion
For js, Since it is single-threaded, in order to prevent js from being "stuck" within a piece of logic, the data can be loaded in segments