CN109558572B - Chart adjusting method and device - Google Patents

Chart adjusting method and device Download PDF

Info

Publication number
CN109558572B
CN109558572B CN201710888969.0A CN201710888969A CN109558572B CN 109558572 B CN109558572 B CN 109558572B CN 201710888969 A CN201710888969 A CN 201710888969A CN 109558572 B CN109558572 B CN 109558572B
Authority
CN
China
Prior art keywords
legend
width
container
height
parameter
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN201710888969.0A
Other languages
Chinese (zh)
Other versions
CN109558572A (en
Inventor
蔡炜麟
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Beijing Gridsum Technology Co Ltd
Original Assignee
Beijing Gridsum Technology Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Beijing Gridsum Technology Co Ltd filed Critical Beijing Gridsum Technology Co Ltd
Priority to CN201710888969.0A priority Critical patent/CN109558572B/en
Publication of CN109558572A publication Critical patent/CN109558572A/en
Application granted granted Critical
Publication of CN109558572B publication Critical patent/CN109558572B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F40/00Handling natural language data
    • G06F40/10Text processing
    • G06F40/166Editing, e.g. inserting or deleting
    • G06F40/174Form filling; Merging
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F40/00Handling natural language data
    • G06F40/10Text processing
    • G06F40/103Formatting, i.e. changing of presentation of documents
    • G06F40/106Display of layout of documents; Previewing

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Health & Medical Sciences (AREA)
  • Artificial Intelligence (AREA)
  • Audiology, Speech & Language Pathology (AREA)
  • Computational Linguistics (AREA)
  • General Health & Medical Sciences (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Controls And Circuits For Display Device (AREA)

Abstract

The invention provides a chart adjusting method and a device, which are used for obtaining the width of a legend container in a chart and the width and the height of each legend in at least one legend, determining the target row number of the legend container according to the width of the legend container and the width of each legend, and finally determining the target row number of the legend container and the height of each legend, and adjusting the target height of the legend container to enable the target height of the legend container in the chart to be adaptive to the size characteristics of each legend, so that the dynamic adjustment process of the legend container is realized, and the normal display of the Echarts chart can be still ensured when the number of the legends of the Echarts chart changes.

Description

Chart adjusting method and device
Technical Field
The present invention relates to the field of information processing, and in particular, to a method and an apparatus for adjusting a chart.
Background
In the data report display of a large business system, various charts are often used to show the development trend of various data indexes over time, for example, echarts is a common tool for solving the demand. However, in the Echarts chart, the height of a legend (Legend) container is usually fixed after the container is generated, however, the number of legends is dynamically changed along with data interaction between a user and the chart, and therefore, the placement position of the legends sometimes exceeds the range of the legend container, which causes the typesetting disorder, and even blocks graphs such as line graphs and bar graphs in the chart.
According to the traditional solution scheme, before generating the legend container in the Echarts chart, the maximum value of possible legend numbers is estimated, and then a maximum height value is set for the legend container according to the maximum value of the legend numbers, so that the legend container is generated according to the maximum height value, and the situation that the legend placing position exceeds the height range of the legend container is avoided when the legend numbers are dynamically changed. However, the number of the legends in the dynamic change process may be far smaller than the estimated maximum value, which in turn may cause a large blank area to be left in the legend container, thereby wasting the display space of the legend container and affecting the display effect of the Echarts chart. Moreover, when the randomness of the number of legends is large, so that the maximum value cannot be estimated, the conventional solution loses feasibility, and thus the implementation cannot be realized.
Therefore, there is a need for a technical solution that can ensure that the Echarts chart can be normally displayed when the number of legends of the Echarts chart changes.
Disclosure of Invention
In view of this, the present invention provides a chart adjusting method and device, so as to solve the technical problem that normal display of an Echarts chart cannot be guaranteed when the number of legends of the Echarts chart changes at present.
In order to achieve the purpose, the invention provides the following technical scheme:
a chart adjusting method comprises a legend container and at least one legend; the method comprises the following steps:
acquiring the width of the legend container, and the width and the height of each legend in the at least one legend;
determining a target row number of the legend container according to the width of the legend container and the width of each legend;
and adjusting the target height of the legend container according to the target row number of the legend container and the height of each legend.
Preferably, the obtaining the width of each legend in the at least one legend includes:
respectively obtaining the width of legend marks, the width of legend characters and the width of horizontal intervals in each legend;
the width of each legend is determined according to the sum of the width of the legend mark, the width of the legend character and the width of the horizontal interval in each legend.
Preferably, the obtaining the heights of the legends in the at least one legend includes:
acquiring the height of legend marks, the height of legend characters and the height of vertical intervals in any legend;
acquiring the maximum value of the height of the legend mark and the height of the legend text;
determining the height of each legend based on the sum of the maximum value and the height of the vertical spacing.
Preferably, the determining the target number of rows of the legend container according to the width of the legend container and the width of each legend comprises:
dividing the at least one legend into N groups according to the width of the legend container and the width of each legend, wherein the total width of all legends in any group is not more than the width of the legend container, and N is more than or equal to 1;
and determining the target row number of the legend container according to the value of N.
Preferably, the legend container includes a row number parameter and a Yu Kuan parameter; determining the target number of rows of the legend container based on the width of the legend container and the width of the legends comprises:
when the width of the current legend is greater than the current value of the Yu Kuan parameter, determining the difference between the width of the legend container and the width of the current legend as the latest value of the Yu Kuan parameter, and determining the current value of the row number parameter after increasing by a preset step size as the latest value of the row number parameter;
when the width of the current legend is not greater than the current value of the Yu Kuan parameter, determining the difference between the current value of the margin parameter and the width of the current legend as the latest value of the Yu Kuan parameter;
judging whether the current legend is the last legend in the at least one legend, if not, taking the latest value of the residual width parameter as the current value of the residual width parameter, taking the latest value of the line number parameter as the current value of the line number parameter, and executing the steps again; if yes, determining the target line number of the legend container according to the latest value of the line number parameter.
Preferably, the illustrated container includes a height parameter; the adjusting the target height of the legend container according to the target number of rows of the legend containers and the height of each legend comprises:
determining a product of the target number of rows of the legend container and the height of the legend as a height parameter value for the legend container;
and adjusting the target height of the legend container according to the height parameter value of the legend container.
Preferably, the legend text includes the number of texts, the font height and the font width;
the width of the legend characters is the product of the number of the characters and the width of the fonts;
the height of the legend text is the font height.
A chart adjusting device comprises a legend container and at least one legend; the device comprises:
the data acquisition unit is used for acquiring the width of the legend container and the width and the height of each legend in the legend;
a line number determining unit, configured to determine a target line number of the legend container according to the width of the legend container and the width of each legend;
and the chart adjusting unit is used for adjusting the target height of the legend container according to the target row number of the legend container and the height of each legend.
A storage medium comprising a stored program, wherein the program, when executed, controls a device on which the storage medium is located to perform any one of the aforementioned graph adjustment methods.
A processor for running a program, wherein the program when running performs any of the aforementioned graph adjustment methods.
According to the technical scheme, the method and the device for adjusting the chart, provided by the invention, the width of the legend container in the chart and the width and height of each legend in at least one legend are obtained, the target line number of the legend container is determined according to the width of the legend container and the width of each legend, and finally the target height of the legend container is adjusted according to the target line number of the legend container and the height of each legend, so that the target height of the legend container in the chart can be adapted to the size characteristics of each legend, a dynamic adjustment process of the legend container is realized, and the normal display of the Echarts chart can be still ensured when the legend number of the Echarts chart changes.
Drawings
In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings used in the embodiments or the prior art descriptions will be briefly described below, it is obvious that the drawings in the following description are only embodiments of the present invention, and for those skilled in the art, other drawings can be obtained according to the provided drawings without creative efforts.
Fig. 1 is a flowchart of a chart adjustment method according to an embodiment of the present disclosure;
FIG. 2 is another flow chart of a chart adjustment method according to an embodiment of the present disclosure;
FIG. 3 is a flowchart of a chart adjustment method according to an embodiment of the present disclosure;
FIG. 4 is a flowchart of another method for adjusting a chart according to an embodiment of the present disclosure;
FIG. 5 is a schematic diagram of a diagram adjusting apparatus according to an embodiment of the present disclosure;
FIG. 6 is a schematic structural diagram of a chart adjustment apparatus according to an embodiment of the present disclosure;
FIG. 7 is a schematic structural diagram of a chart adjustment apparatus according to an embodiment of the present disclosure;
FIG. 8 is a schematic structural diagram of a chart adjustment apparatus according to an embodiment of the present disclosure;
fig. 9 is a schematic structural diagram of an example provided in the present application.
Detailed Description
For the sake of reference and clarity, the descriptions, abbreviations or abbreviations of the technical terms used hereinafter are summarized as follows:
the technical solutions in the embodiments of the present invention will be clearly and completely described below with reference to the drawings in the embodiments of the present invention, and it is obvious that the described embodiments are only a part of the embodiments of the present invention, and not all of the embodiments. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present invention.
According to the chart adjusting method and device, the target height of the legend container is adjusted according to the width of the legend container in the chart and the height and width of each legend, so that the target height of the legend container in the chart can be adapted to the size characteristics of each legend, and the technical problem that normal display of an Echarts chart cannot be guaranteed when the number of legends of the Echarts chart changes at present is solved. However, the technical solution of the present invention is not only suitable for normally displaying the Echarts chart, but also suitable for normally displaying other charts having similar architecture or similar technical problems with the Echarts chart. Therefore, the "charts" mentioned in the embodiments of the present invention include various kinds of charts having technical problems solved by the present invention, and are not limited to the Echarts charts.
Referring to fig. 1, fig. 1 is a flowchart of a chart adjustment method according to an embodiment of the present disclosure.
In practical applications, the chart usually includes a legend and a legend container for carrying the legend, in addition to the chart bodies such as line charts, bar charts, pie charts and the like.
As shown in fig. 1, the method includes:
s101: the width of the legend container, and the width and height of each legend in the at least one legend are obtained.
In a chart, the maximum width of the legend container is limited by the maximum width of the chart interface, and the height of the chart interface is generally unlimited, so the maximum height of the legend container is also generally unlimited. The heights of the legends in the diagram are generally the same, but because the number of characters in the legend characters in each legend may be the same or may be different, the widths of the legends may be the same or may be different.
S102: and determining the target row number of the legend container according to the width of the legend container and the width of each legend.
The legend container in the chart is used for carrying at least one legend in the chart, and the legends are generally arranged in rows in the legend container, so that on the premise that the width of the legend container and the width of each legend are known, the number of rows required for arranging all the at least one legend in the legend container can be determined according to the width of the legend container and the width of each legend, and therefore the number of rows required by the legend container for carrying the at least one legend is determined.
S103: and adjusting the target height of the legend container according to the target row number of the legend container and the height of each legend.
When the legends are arranged in rows in the legend container, in order to avoid the mutual shielding between the legends in the upper and lower rows, the height (height) of each row in the legend container needs to be not less than the height of the legend.
In one example, the legend container includes a height parameter. The step S103 includes:
a. determining the target line height of the legend container according to the height of the legend.
Wherein the legend container has a target height greater than the legend height.
b. Determining a product of the target row number for the legend container and the target row height for the legend container as the height parameter value for the legend container.
c. And adjusting the target height of the legend container according to the height parameter value of the legend container. Wherein the target height of the legend container is not less than the height parameter value.
In another example, the legend container includes a height parameter. The step S103 includes:
a. determining a product of the target number of rows of the legend container and the height of the legend as a height parameter value for the legend container.
b. And adjusting the target height of the legend container according to the height parameter value of the legend container. Wherein the target height of the illustrated container is equal to the height parameter value.
The illustrative container includes a height parameter. The height of the legend is determined as the target line height of the legend container.
In this example, the product of the target row number of the legend container and the height of the legend is directly determined as the height parameter value of the legend container, which is equivalent to determining the height of the legend as the target row height of the legend container, and making the target height of the legend container equal to the height parameter value, thus not only ensuring the normal display of the legends in the legend container, but also ensuring the space utilization rate of the legend container and avoiding the waste of display space.
According to the chart adjusting method provided by the embodiment, the target height of the legend container is adjusted according to the width of the legend container and the height and width of each legend, so that the target height of the legend container in the chart can be adapted to the size characteristics of each legend, and the dynamic adjusting process of the legend container is realized, so that the normal display of the Echarts chart can be still ensured when the number of legends of the Echarts chart changes.
Referring to fig. 2, fig. 2 is another flowchart of a chart adjustment method according to an embodiment of the present disclosure.
In the present embodiment, as shown in fig. 9, the legend 1 is composed of legend marks 11, legend letters 12, horizontal spaces 13, and vertical spaces 14. The horizontal interval 13 of the legend refers to a blank area adjacent to the left or right border of the legend, and the vertical interval 14 of the legend refers to a blank area adjacent to the upper or lower border of the legend.
As shown in fig. 2, the method includes:
s201: the width of the legend container is taken.
S202: the width of the legend mark, the width of the legend text and the width of the horizontal interval in each legend are respectively obtained.
S203: the width of each legend is determined according to the sum of the width of the legend mark, the width of the legend character and the width of the horizontal interval in each legend.
The width of the legend marks, the width of the legend text, and the width of the horizontal spaces in the legend determine the width of the legend.
In a specific example, the sum of the width of the legend mark, the width of the legend text, and the width of the horizontal space in each legend is determined as the width of each legend, respectively.
S204: the height of the legend marks, the height of the legend text, and the height of the vertical spacing in any legend are obtained.
S205: and acquiring the maximum value of the height of the legend mark and the height of the legend text.
S206: the height of each legend is determined based on the sum of the maximum value and the height of the vertical spacing.
Wherein the sum of the maximum value and the height of the vertical interval is the height of any one of the legends.
The height of the legend marks in the legend, the height of the legend text, and the height of the vertical spaces together determine the width of the legend. Since the height of each legend in the chart is the same, the height of each legend can be determined based on the height of any legend.
In a specific example, the sum of the maximum value and the height of the vertical interval is determined as the height of each legend.
S207: and determining the target row number of the legend container according to the width of the legend container and the width of each legend.
S208: and adjusting the target height of the legend container according to the target row number of the legend container and the height of each legend.
In one example, the legend text includes the number of text, the font height, and the font width.
The width of the legend characters is the product of the number of the characters and the width of the fonts; the height of the legend text is the font height.
Steps S207 to S208 are similar to steps S102 to S103 in the foregoing embodiment, and are not repeated here.
The chart adjusting method provided in this embodiment determines the width of each legend according to the sum of the width of the legend mark, the width of the legend text and the width of the horizontal interval in each legend, determines the height of each legend according to the sum of the maximum value of the height of the legend mark and the height of the legend text in each legend and the height of the vertical interval, improves the accuracy of obtaining the height and the width of each legend, and further adjusts the target height of the legend container according to the width of the legend container and the height and the width of each legend, thereby further ensuring the adaptability of the target height of the legend container in the chart and the size characteristics of each legend.
Referring to fig. 3, fig. 3 is a flowchart of a chart adjustment method according to an embodiment of the present disclosure.
As shown in fig. 3, the method includes:
s301: the width of the legend container, and the width and height of each legend in the at least one legend are obtained.
Wherein, the step S301 can be realized by executing the steps S201 to S206 in the foregoing embodiment.
S302: dividing the at least one legend into N groups based on the width of the legend container and the width of each legend.
Wherein the total width of all legends in any group is not greater than the width of legend container, N ≧ 1.
One or more legends may be placed in each row of legend containers, and the total width of the legends in each row is required to be no greater than the width of the legend container in order to ensure that the legends do not exceed the horizontal boundaries of the legend containers when placed according to the width of the legends and the width of the legend containers. Thus, at least one legend may be divided into N groups such that the total width of all legends in any group is no greater than the width of the legend container, such that placing each group of legend instances separately in each row of the legend container ensures proper display of the legends in the legend container.
S303: and determining the target row number of the legend container according to the value of N.
In one example, the target row number of the legend container is equal to the value of N, so that each group of legend cases is just placed in each row of the legend container, thereby not only ensuring the normal display of each legend in the legend container, but also ensuring the space utilization rate of the legend container and avoiding the waste of display space.
S304: and adjusting the target height of the legend container according to the target row number of the legend container and the height of each legend.
The step S304 is similar to the step S103 in the previous embodiment, and is not described herein again.
In the method for adjusting a chart provided in this embodiment, at least one legend is divided into N groups according to the width of the legend container and the width of each legend, so that the total width of all legends in any group is not greater than the width of the legend container, and then the target row number of the legend container is determined according to the value of N, thereby determining the target row number of the legend container, and the target height of the legend container is adjusted according to the target row number of the legend container and the height of each legend, thereby further ensuring the adaptability of the target height of the legend container in the chart to the size characteristics of each legend.
Please refer to the drawings
Figure BDA0001420747380000101
Fig. 4 is another flowchart of a chart adjustment method according to an embodiment of the present disclosure.
In this embodiment, the legend container includes a row number parameter and Yu Kuan parameter, and the row number parameter and Yu Kuan parameter are both variables, and are applied to the operation process for determining the target row number of the legend container according to the width of the legend container and the width of each legend. The line number parameter is used to dynamically indicate the target line number required by the legend container in the operation process, and the Yu Kuan parameter is used to dynamically indicate the remaining width of the current line of the legend container in the operation process.
As shown in fig. 4, the method includes:
s401: the width of the legend container is obtained, as well as the width and height of each legend in the at least one legend.
Wherein, this step S401 can be realized by executing steps S201 to S206 in the foregoing embodiment.
S402: judging whether the width of the current legend is greater than the current value of the Yu Kuan parameter, if so, executing step S403; if not, go to step S404.
Judging whether the width of the current legend is larger than the current value of the margin parameter, if so, indicating that the current row of the legend container is not enough to accommodate the current legend; if the width of the current legend is not greater than the current value of the Yu Kuan parameter, it indicates that the current row of the legend container can hold the current legend.
S403: and determining the difference between the width of the legend container and the width of the current legend as the latest value of the Yu Kuan parameter, and determining the current value of the row number parameter as the latest value of the row number parameter after increasing by a preset step length.
When the width of the current legend is greater than the current value of the margin parameter, the current value of the line number parameter is increased by a preset step length and then determined as the latest value of the line number parameter, namely line feed processing is carried out, meanwhile, the value of the margin parameter is reset, and the difference value between the width of the pattern container and the width of the current legend is determined as the latest value of the margin parameter.
When the current legend is the first legend, the current values of the Yu Kuan parameter and the row number parameter are the respective initial values.
In a specific example, the width totalWidth =50px for the legend container, the initial values of the line number parameter rowNum and Yu Kuan parameter surfluxwidth are both 0, the preset step stepLen =1, and the width of the first legend is legendWidth [1] =8px. Obviously, legedwidth [1] > superlusswidth, the latest value of suplusswidth is calculated to be 42px using the formula suplusswidth = totalWidth-legedwidth [1], and the latest value of rowNum is iteratively calculated to be 1 using the formula rowNum = rowNum + stepLen.
In other examples, the initial value of the line number parameter rowNum is 1, and the initial value of the residual width parameter supplus width is the width totalWidth of the legend container.
S404: and determining the difference value between the current value of the margin parameter and the width of the current legend as the latest value of the Yu Kuan parameter.
When the width of the current legend is not greater than the current value of the Yu Kuan parameter, it is indicated that the current legend can be continuously placed in the current line of the legend container, so that line feed processing is not needed, the value of the residual width parameter is updated according to the current value of the Yu Kuan parameter and the width of the current legend, and the difference between the current value of the residual width parameter and the width of the current legend is determined as the latest value of the residual width parameter.
S405: judging whether the current legend is the last legend in the at least one legend, if not, executing step S406; if yes, go to step S407;
s406: taking the latest value of the residual width parameter as the current value of the residual width parameter, taking the latest value of the line number parameter as the current value of the line number parameter, and executing the steps S402-S405 again;
s407: and determining the target row number of the legend container according to the latest value of the row number parameter.
After all of the above steps S402-S406 have been performed based on all of the legends, all of the legends may be placed in the legend container, at which point the most recent value of the row number parameter characterizes the minimum number of rows that the legend container can accommodate all of the legends.
In one example, the target row number of the legend container is equal to the latest value of the row number parameter, so that each group of legend cases is just placed in each row of the legend container, normal display of each legend in the legend container is guaranteed, the space utilization rate of the legend container is also guaranteed, and waste of display space is avoided.
S408: and adjusting the target height of the legend container according to the target row number of the legend container and the height of each legend.
The step S408 is similar to the step S103 in the previous embodiment, and is not repeated herein.
In the method for adjusting a chart provided in this embodiment, the residual width parameter and the line number parameter of the legend container are iteratively updated according to the size relationship between the width of each legend and the current value of the residual width parameter of the legend container, so as to obtain the latest value of the line number parameter, the target line number of the legend container is determined according to the latest value of the line number parameter, and the target height of the legend container is adjusted according to the target line number of the legend container and the height of each legend, so that the adaptability between the target height of the legend container in the chart and the size characteristics of each legend is further ensured.
The units of elements related to the width of the legend container, the target height of the legend container, the width of the legend, the height of the legend, the width of the legend marks, the height of the legend characters, the width of the horizontal intervals, the height of the vertical intervals, the font height and font width, the current value of the margin parameter, the latest value of the margin parameter, and the height parameter value of the legend container in the embodiment of the invention are the same. For example, the units of the elements are pixels (px) or millimeters (mm).
Corresponding to the chart adjusting method, the embodiment of the invention also provides a corresponding chart adjusting device.
Referring to fig. 5, fig. 5 is a schematic structural diagram of a chart adjusting device according to an embodiment of the present disclosure.
The chart adjusting apparatus of the present embodiment is used for implementing the chart adjusting method of the foregoing embodiment, and as shown in fig. 5, the apparatus includes:
and the data acquisition unit U101 is used for acquiring the width of the legend container and the width and the height of each legend in the at least one legend.
And the row number determining unit U102 is used for determining the target row number of the legend container according to the width of the legend container and the width of each legend.
And the chart adjusting unit U103 is used for adjusting the target height of the legend container according to the target row number of the legend container and the height of each legend.
The chart adjusting device provided by this embodiment adjusts the target height of the legend container according to the width of the legend container and the height and width of each legend, so that the target height of the legend container in the chart can be adapted to the size characteristics of each legend, and a dynamic adjusting process of the legend container is realized, thereby ensuring normal display of the Echarts chart when the number of legends of the Echarts chart changes.
Referring to fig. 6, fig. 6 is another schematic structural diagram of a chart adjusting apparatus according to an embodiment of the present disclosure.
The chart adjusting apparatus of the present embodiment includes the data acquiring unit U101, the line number determining unit U102, and the chart adjusting unit U103 in the foregoing embodiments. Wherein the data acquisition unit U101 includes:
the first obtaining unit U1011 is configured to obtain a width of a legend mark, a width of a legend character, and a width of a horizontal interval in each legend, respectively.
A first determining unit U1012, configured to determine the width of each legend according to the sum of the width of the legend mark, the width of the legend text, and the width of the horizontal interval in each legend.
The second obtaining unit U1013 is configured to obtain the height of the legend mark, the height of the legend text, and the height of the vertical interval in any one legend.
And the maximum value taking unit U1014 is used for acquiring the maximum value of the heights of the legend marks and the legend characters.
A second determining unit U1015, configured to determine the heights of the legends according to the sum of the maximum value and the height of the vertical interval.
The chart adjusting device provided in this embodiment determines the width of each legend according to the sum of the width of the legend mark in each legend, the width of the legend text and the width of the horizontal interval, determines the height of each legend according to the sum of the maximum value of the height of the legend mark in each legend and the height of the vertical interval, improves the accuracy of obtaining the height and the width of each legend, and further adjusts the target height of the legend container according to the width of the legend container and the height and the width of each legend, thereby further ensuring the adaptability of the target height of the legend container in the chart and the size characteristics of each legend.
Referring to fig. 7, fig. 7 is a schematic structural diagram of a chart adjusting apparatus according to an embodiment of the present disclosure.
The chart adjusting apparatus of this embodiment includes the data obtaining unit U101, the line number determining unit U102, and the chart adjusting unit U103 in the foregoing embodiment, where the line number determining unit U102 includes:
and the legend grouping unit U1021 is used for dividing the at least one legend into N groups according to the width of the legend container and the width of each legend.
Wherein the total width of all legends in any group is not more than the width of the legend container, and N is more than or equal to 1.
And a third determining unit U1022, configured to determine the target number of rows of the legend container according to the value of N.
The chart adjusting device provided in this embodiment divides at least one legend into N groups according to the width of the legend container and the width of each legend, so that the total width of all legends in any group is not greater than the width of the legend container, determines the target row number of the legend container according to the value of N, determines the target row number of the legend container, and adjusts the target height of the legend container according to the target row number of the legend container and the height of each legend, thereby further ensuring the adaptability of the target height of the legend container in the chart to the size characteristics of each legend.
Referring to fig. 8, fig. 8 is a schematic structural diagram of a chart adjusting apparatus according to an embodiment of the present disclosure.
The chart adjusting apparatus of this embodiment includes the data obtaining unit U101, the line number determining unit U102, and the chart adjusting unit U103 in the foregoing embodiment, where the legend container includes a line number parameter and a Yu Kuan parameter, and initial values of the line number parameter and the residual width parameter are respectively corresponding preset values. Wherein the row number determining unit U102 includes: the line number updating unit U1023, the residual width updating unit U1024, the iteration control unit U1025 and the fourth determining unit U1026;
the row number updating unit U1023 is configured to, when the width of the current legend is greater than the current value of the Yu Kuan parameter, determine the difference between the width of the legend container and the width of the current legend as the latest value of the Yu Kuan parameter, and determine the current value of the row number parameter as the latest value of the row number parameter after increasing by a preset step size.
Yu Kuan updating unit U1024 for determining the difference between the current value of the margin parameter and the width of the current legend as the latest value of the Yu Kuan parameter when the width of the current legend is not greater than the current value of the Yu Kuan parameter.
The iteration control unit U1025 is configured to determine whether the current legend is the last legend in the at least one legend, and if not, take the latest value of the residual width parameter as the current value of the residual width parameter, take the latest value of the line number parameter as the current value of the line number parameter, and instruct the line number updating unit U1023 and the wide updating unit U1024 to execute their functions again; if yes, the fourth determination unit U1026 is instructed to perform its function;
a fourth determining unit U1026, configured to determine the target line number of the legend container according to the latest value of the line number parameter.
The chart adjusting device provided in this embodiment iteratively updates the residual width parameter and the line number parameter of the legend container according to the size relationship between the width of each legend and the current value of the residual width parameter of the legend container, obtains the latest value of the final line number parameter, determines the target line number of the legend container according to the latest value of the line number parameter, and adjusts the target height of the legend container according to the target line number of the legend container and the height of each legend, thereby further ensuring the adaptability of the target height of the legend container in the chart and the dimensional characteristics of each legend.
The graph adjusting apparatus provided in an embodiment of the present invention includes a processor and a memory, where the data obtaining unit U101, the line number determining unit U102, the graph adjusting unit U103, the first obtaining unit U1011, the first determining unit U1012, the second obtaining unit U1013, the maximum value obtaining unit U1014, the second determining unit U1015, the legend grouping unit U1021, the third determining unit U1022, the line number updating unit U1023, the remaining width updating unit U1024, the iteration control unit U1025, the fourth determining unit U1026, and the like are stored in the memory as program units, and the processor executes the program units stored in the memory to implement corresponding functions.
The processor comprises a kernel, and the kernel calls the corresponding program unit from the memory. The kernel can be set to be one or more than one, and the technical problem that normal display of the Echarts chart cannot be guaranteed when the number of legends of the Echarts chart changes at present is solved by adjusting the kernel parameters.
The memory may include volatile memory in a computer readable medium, random Access Memory (RAM) and/or nonvolatile memory such as Read Only Memory (ROM) or flash memory (flash RAM), and the memory includes at least one memory chip.
The embodiment of the invention provides a storage medium, which comprises a stored program, wherein when the program runs, a device where the storage medium is located is controlled to execute any one of the chart adjusting methods.
An embodiment of the present invention provides a processor, where the processor is configured to execute a program, where the program executes any one of the graph adjustment methods described above when running.
The embodiment of the invention provides equipment, which comprises a processor, a memory and a program which is stored on the memory and can run on the processor, wherein the processor executes the program and realizes the following steps:
acquiring the width of the legend container, and the width and the height of each legend in the at least one legend;
determining a target row number of the legend container according to the width of the legend container and the width of each legend;
and adjusting the target height of the legend container according to the target row number of the legend container and the height of each legend.
Preferably, the obtaining the width of each legend in the at least one legend includes:
respectively obtaining the width of legend marks, the width of legend characters and the width of horizontal intervals in each legend;
the width of each legend is determined according to the sum of the width of the legend mark, the width of the legend character and the width of the horizontal interval in each legend.
Preferably, the obtaining the heights of the legends in the at least one legend includes:
acquiring the height of a legend mark, the height of legend characters and the height of vertical intervals in any legend;
acquiring the maximum value of the height of the legend mark and the height of the legend text;
determining the height of each legend based on the sum of the maximum value and the height of the vertical spacing.
Preferably, the determining the target number of rows of the legend container according to the width of the legend container and the width of each legend includes:
dividing the legend into N groups according to the width of the legend container and the width of each legend, wherein the total width of all legends in any group is not more than the width of the legend container, and N is more than or equal to 1;
and determining the target row number of the legend container according to the value of N.
Preferably, the legend container includes a row number parameter and a Yu Kuan parameter; determining the target number of rows of the legend container based on the width of the legend container and the width of the legends comprises:
when the width of the current legend is greater than the current value of the Yu Kuan parameter, determining the difference between the width of the legend container and the width of the current legend as the latest value of the Yu Kuan parameter, and determining the current value of the row number parameter as the latest value of the row number parameter after increasing by a preset step size;
when the width of the current legend is not greater than the current value of the Yu Kuan parameter, determining the difference between the current value of the residual width parameter and the width of the current legend as the latest value of the Yu Kuan parameter;
judging whether the current legend is the last legend in the at least one legend, if not, taking the latest value of the residual width parameter as the current value of the residual width parameter, taking the latest value of the line number parameter as the current value of the line number parameter, and executing the steps again; and if so, determining the target line number of the legend container according to the latest value of the line number parameter.
Preferably, the legend container includes a height parameter; the adjusting the target height of the legend container according to the target row number of the legend container and the height of each legend comprises:
determining a product of the target number of rows of the legend container and the height of the legend as a height parameter value for the legend container;
and adjusting the target height of the legend container according to the height parameter value of the legend container.
Preferably, the legend text includes the number of texts, the font height and the font width;
the width of the legend characters is the product of the number of the characters and the width of the fonts;
the height of the legend text is the font height.
The device herein may be a server, a PC, a PAD, a mobile phone, etc.
The present application also provides a computer program product adapted to perform a program for initializing the following method steps when executed on a data processing device:
acquiring the width of the legend container, and the width and the height of each legend in the at least one legend;
determining a target row number of the legend container according to the width of the legend container and the width of each legend;
and adjusting the target height of the legend container according to the target row number of the legend container and the height of each legend.
Preferably, the obtaining the width of each legend in the at least one legend includes:
respectively obtaining the width of legend marks, the width of legend characters and the width of horizontal intervals in each legend;
the width of each legend is determined according to the sum of the width of the legend mark, the width of the legend character and the width of the horizontal interval in each legend.
Preferably, the obtaining the heights of the legends in the at least one legend includes:
acquiring the height of legend marks, the height of legend characters and the height of vertical intervals in any legend;
acquiring the maximum value of the height of the legend mark and the height of the legend text;
determining the height of each legend based on the sum of the maximum value and the height of the vertical spacing.
Preferably, the determining the target number of rows of the legend container according to the width of the legend container and the width of each legend includes:
dividing the at least one legend into N groups according to the width of the legend container and the width of each legend, wherein the total width of all legends in any group is not more than the width of the legend container, and N is more than or equal to 1;
and determining the target row number of the legend container according to the value of N.
Preferably, the legend container includes a row number parameter and a Yu Kuan parameter; determining the target number of rows of the legend container based on the width of the legend container and the width of the legends comprises:
when the width of the current legend is greater than the current value of the Yu Kuan parameter, determining the difference between the width of the legend container and the width of the current legend as the latest value of the Yu Kuan parameter, and determining the current value of the row number parameter after increasing by a preset step size as the latest value of the row number parameter;
when the width of the current legend is not greater than the current value of the Yu Kuan parameter, determining the difference between the current value of the margin parameter and the width of the current legend as the latest value of the Yu Kuan parameter;
judging whether the current legend is the last legend in the at least one legend, if not, taking the latest value of the residual width parameter as the current value of the residual width parameter, taking the latest value of the line number parameter as the current value of the line number parameter, and executing the steps again; and if so, determining the target line number of the legend container according to the latest value of the line number parameter.
Preferably, the legend container includes a height parameter; the adjusting the target height of the legend container according to the target row number of the legend container and the height of each legend comprises:
determining a product of the target number of rows of the legend container and the height of the legend as a height parameter value for the legend container;
and adjusting the target height of the legend container according to the height parameter value of the legend container.
Preferably, the legend text includes the number of texts, the font height and the font width;
the width of the legend characters is the product of the number of the characters and the width of the fonts;
the height of the legend text is the font height.
The present application is described with reference to flowchart illustrations and/or block diagrams of methods, apparatus (systems), and computer program products according to embodiments of the application. It will be understood that each flow and/or block of the flow diagrams and/or block diagrams, and combinations of flows and/or blocks in the flow diagrams and/or block diagrams, can be implemented by computer program instructions. These computer program instructions may be provided to a processor of a general purpose computer, special purpose computer, embedded processor, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, create means for implementing the functions specified in the flowchart flow or flows and/or block diagram block or blocks.
These computer program instructions may also be stored in a computer-readable memory that can direct a computer or other programmable data processing apparatus to function in a particular manner, such that the instructions stored in the computer-readable memory produce an article of manufacture including instruction means which implement the function specified in the flowchart flow or flows and/or block diagram block or blocks.
These computer program instructions may also be loaded onto a computer or other programmable data processing apparatus to cause a series of operational steps to be performed on the computer or other programmable apparatus to produce a computer implemented process such that the instructions which execute on the computer or other programmable apparatus provide steps for implementing the functions specified in the flowchart flow or flows and/or block diagram block or blocks.
In a typical configuration, a computing device includes one or more processors (CPUs), input/output interfaces, network interfaces, and memory.
The memory may include forms of volatile memory in a computer readable medium, random Access Memory (RAM) and/or non-volatile memory, such as Read Only Memory (ROM) or flash memory (flash RAM). The memory is an example of a computer-readable medium.
Computer-readable media, including both non-transitory and non-transitory, removable and non-removable media, may implement information storage by any method or technology. The information may be computer readable instructions, data structures, modules of a program, or other data. Examples of computer storage media include, but are not limited to, phase change memory (PRAM), static Random Access Memory (SRAM), dynamic Random Access Memory (DRAM), other types of Random Access Memory (RAM), read Only Memory (ROM), electrically Erasable Programmable Read Only Memory (EEPROM), flash memory or other memory technology, compact disc read only memory (CD-ROM), digital Versatile Discs (DVD) or other optical storage, magnetic cassettes, magnetic tape magnetic disk storage or other magnetic storage devices, or any other non-transmission medium that can be used to store information that can be accessed by a computing device. As defined herein, a computer readable medium does not include a transitory computer readable medium such as a modulated data signal and a carrier wave.
It should also be noted that the terms "comprises," "comprising," or any other variation thereof, are intended to cover a non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements does not include only those elements but may include other elements not expressly listed or inherent to such process, method, article, or apparatus. Without further limitation, an element defined by the phrase "comprising a … …" does not exclude the presence of another identical element in a process, method, article, or apparatus that comprises the element.
As will be appreciated by one skilled in the art, embodiments of the present application may be provided as a method, system, or computer program product. Accordingly, the present application may take the form of an entirely hardware embodiment, an entirely software embodiment or an embodiment combining software and hardware aspects. Furthermore, the present application may take the form of a computer program product embodied on one or more computer-usable storage media (including, but not limited to, disk storage, CD-ROM, optical storage, and the like) having computer-usable program code embodied therein.
The above are merely examples of the present application and are not intended to limit the present application. Various modifications and changes may occur to those skilled in the art. Any modification, equivalent replacement, improvement or the like made within the spirit and principle of the present application shall be included in the scope of the claims of the present application.

Claims (8)

1. A chart adjusting method is characterized in that a chart comprises a legend container and at least one legend; the legend container includes a row number parameter and a Yu Kuan parameter; the method comprises the following steps:
acquiring the width of the legend container, and the width and the height of each legend in the at least one legend;
when the width of the current legend is greater than the current value of the Yu Kuan parameter, determining the difference between the width of the legend container and the width of the current legend as the latest value of the Yu Kuan parameter, and determining the current value of the row number parameter after increasing by a preset step size as the latest value of the row number parameter;
when the width of the current legend is not greater than the current value of the Yu Kuan parameter, determining the difference between the current value of the margin parameter and the width of the current legend as the latest value of the Yu Kuan parameter;
judging whether the current legend is the last legend in the at least one legend, if not, taking the latest value of the residual width parameter as the current value of the residual width parameter, taking the latest value of the line number parameter as the current value of the line number parameter, and executing the steps again; if yes, determining the target line number of the legend container according to the latest value of the line number parameter;
and adjusting the target height of the legend container according to the target row number of the legend container and the height of each legend.
2. The method of claim 1, wherein said obtaining a width for each legend in said at least one legend comprises:
respectively obtaining the width of the legend mark, the width of the legend characters and the width of the horizontal interval in each legend;
and determining the width of each legend according to the sum of the width of the legend mark, the width of the legend character and the width of the horizontal interval in each legend.
3. The method of claim 1, wherein said obtaining a height of each legend in said at least one legend comprises:
acquiring the height of legend marks, the height of legend characters and the height of vertical intervals in any legend;
acquiring the maximum value of the height of the legend mark and the height of the legend text;
determining the height of each legend based on the sum of the maximum value and the height of the vertical spacing.
4. The method of claim 1, wherein the legend container includes a height parameter; the adjusting the target height of the legend container according to the target row number of the legend container and the height of each legend comprises:
determining a product of the target number of rows of the legend container and the height of the legend as a height parameter value for the legend container;
and adjusting the target height of the legend container according to the height parameter value of the legend container.
5. A method according to claim 2 or 3, wherein said legend text includes text number, font height and font width;
the width of the legend characters is the product of the number of the characters and the width of the fonts;
the height of the legend text is the font height.
6. A chart adjustment device, wherein the chart comprises a legend container and at least one legend; the legend container includes a line number parameter and a Yu Kuan parameter; the device comprises:
the data acquisition unit is used for acquiring the width of the legend container and the width and the height of each legend in the legend;
a row number determining unit, configured to determine, when the width of the current legend is greater than the current value of the Yu Kuan parameter, a difference between the width of the legend container and the width of the current legend as a latest value of the Yu Kuan parameter, and determine, after the current value of the row number parameter is incremented by a preset step size, the latest value of the row number parameter; when the width of the current legend is not greater than the current value of the Yu Kuan parameter, determining the difference between the current value of the margin parameter and the width of the current legend as the latest value of the Yu Kuan parameter; judging whether the current legend is the last legend in the at least one legend, if not, taking the latest value of the residual width parameter as the current value of the residual width parameter, taking the latest value of the line number parameter as the current value of the line number parameter, and executing the steps again; if yes, determining the target line number of the legend container according to the latest value of the line number parameter;
and the chart adjusting unit is used for adjusting the target height of the legend container according to the target row number of the legend container and the height of each legend.
7. A storage medium characterized by comprising a stored program, wherein a device on which the storage medium is located is controlled to execute the chart adjusting method according to any one of claims 1 to 5 when the program is executed.
8. A processor, characterized in that the processor is configured to run a program, wherein the program when running performs the graph adjustment method according to any one of claims 1-5.
CN201710888969.0A 2017-09-27 2017-09-27 Chart adjusting method and device Active CN109558572B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201710888969.0A CN109558572B (en) 2017-09-27 2017-09-27 Chart adjusting method and device

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201710888969.0A CN109558572B (en) 2017-09-27 2017-09-27 Chart adjusting method and device

Publications (2)

Publication Number Publication Date
CN109558572A CN109558572A (en) 2019-04-02
CN109558572B true CN109558572B (en) 2022-11-22

Family

ID=65863635

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201710888969.0A Active CN109558572B (en) 2017-09-27 2017-09-27 Chart adjusting method and device

Country Status (1)

Country Link
CN (1) CN109558572B (en)

Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN106557315A (en) * 2016-11-04 2017-04-05 北京神州绿盟信息安全科技股份有限公司 A kind of Web panel layouts method and apparatus
CN106649317A (en) * 2015-10-29 2017-05-10 北京国双科技有限公司 Method and device for displaying graph
CN106775600A (en) * 2015-11-19 2017-05-31 北京国双科技有限公司 The processing method and processing device of HTML5 canvas painting canvas

Family Cites Families (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US9552557B2 (en) * 2012-02-16 2017-01-24 Microsoft Technology Licensing, Llc Visual representation of chart scaling

Patent Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN106649317A (en) * 2015-10-29 2017-05-10 北京国双科技有限公司 Method and device for displaying graph
CN106775600A (en) * 2015-11-19 2017-05-31 北京国双科技有限公司 The processing method and processing device of HTML5 canvas painting canvas
CN106557315A (en) * 2016-11-04 2017-04-05 北京神州绿盟信息安全科技股份有限公司 A kind of Web panel layouts method and apparatus

Also Published As

Publication number Publication date
CN109558572A (en) 2019-04-02

Similar Documents

Publication Publication Date Title
CN105378653B (en) Application widget is intelligently inserted into managed display segments
EP3279866A1 (en) Method and apparatus for generating synthetic picture
CN108961147B (en) Data processing method and device
JP2019513268A (en) Mixed view display method and device
CN104794116A (en) Layout method and device for elements in page
CN108460003B (en) Text data processing method and device
US11620503B2 (en) Neural network processing
CN109460540A (en) A kind of table paging display methods and device
CN111443974A (en) Android device screen adapting method, related device and readable storage medium
CN107423366B (en) Carousel graph switching method and device
CN110633437A (en) Method and device for omitting display of multiple lines
CN109857964B (en) Thermodynamic diagram drawing method and device for page operation, storage medium and processor
CN109558572B (en) Chart adjusting method and device
CN109948083B (en) Webpage processing method and device
CN109582188B (en) Method, device and related equipment for realizing element positioning in popup window
CN110968811A (en) Display control method and device
CN111209009A (en) Content distribution method and device, storage medium and electronic equipment
CN107016303B (en) Information display method and device
CN113961184A (en) Page layout processing method and device, storage medium and electronic equipment
CN111866597B (en) Method, system and storage medium for controlling layout of page elements in video
CN110321124B (en) Text layout optimization method and device and electronic equipment
CN113867862A (en) List page layout method and computing device
CN114820729A (en) Element one-key layout method and device
CN112800357A (en) Web page presenting method, device, equipment and storage medium
CN110020285B (en) Histogram processing method and device

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
CB02 Change of applicant information

Address after: 100080 No. 401, 4th Floor, Haitai Building, 229 North Fourth Ring Road, Haidian District, Beijing

Applicant after: BEIJING GRIDSUM TECHNOLOGY Co.,Ltd.

Address before: 100086 Beijing city Haidian District Shuangyushu Area No. 76 Zhichun Road cuigongfandian 8 layer A

Applicant before: BEIJING GRIDSUM TECHNOLOGY Co.,Ltd.

CB02 Change of applicant information
GR01 Patent grant
GR01 Patent grant