Stacked histogram proportion determination method and device based on Echarts, equipment and medium
By filtering, summing, converting and allocating data proportions, and combining the Echarts tool to draw stacked bar charts, the problem of inaccurate proportions in stacked bar charts is solved, and the generation efficiency and accuracy are improved.
Patent Information
- Application Number
- CN202510708340.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-05-29
- Publication Date
- 2025-10-21
AI Technical Summary
In the prior art, the sum of the data percentage results of the stacked bar chart is not necessarily equal to 100%, resulting in low efficiency in generating the stacked bar chart.
Initial data is obtained by receiving data collection requests, the target data is filtered, the sum is processed and converted into percentages according to the preset accuracy, the maximum balance method is used to allocate the proportions, and the Echarts tool is used to draw a stacked bar chart.
The sum of the proportions of each target is achieved to 100%, which improves the efficiency of generating stacked bar charts and makes data display more accurate and intuitive.
Smart Images

Figure CN120821771A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of data visualization technology, and in particular to a method, device, equipment and medium for determining the proportion of a stacked bar chart based on Echarts. Background Art
[0002] In the era of big data, data processing and visualization technologies have been widely used in various fields. Through data processing and visualization technologies, single data can be presented through appropriate visualization chart types, so that the trends and distribution of data can be displayed more intuitively.
[0003] In front-end development, data visualization requires relying on a chart library. Echarts is one of the most common chart libraries. Using Echarts for data visualization can quickly and easily generate intuitive, vivid, interactive, and highly customizable data visualization charts.
[0004] In existing data visualization research, stacked bar charts are often used as an important presentation method. However, when calculating the percentage of each data point in a stacked bar chart, the sum of the calculated data percentages may not always equal 100%. This requires manual review and reconfirmation, which wastes manpower and time, resulting in low efficiency in generating stacked bar charts. Summary of the Invention
[0005] Based on this, it is necessary to provide a method, device, equipment and medium for determining the proportion of stacked bar charts based on Echarts to address the above technical problems, so as to solve the problem in the existing technology that the sum of the proportion results of stacked bar charts is not necessarily equal to 100%, resulting in low efficiency in generating stacked bar charts.
[0006] A method for determining the proportion of a stacked bar chart based on Echarts, comprising: receiving a data collection request to obtain initial data of at least one target type in different target platforms, and filtering out target data corresponding to each of the target platforms; the target data refers to the initial data of all target types corresponding to the same target platform; Obtain a data share request to sum all the target data corresponding to the same target platform to obtain a total sum corresponding to each target platform; Determine the data result of dividing each target data in the same target platform by the total sum value according to a preset precision, and convert each data result into a data proportion as a percentage; the preset precision is used to represent the number of decimal places retained; Allocating all data proportions corresponding to each target platform using the maximum balance method to obtain a target proportion corresponding to each target data in the same target platform; wherein the sum of all target proportions is 100%; Receive a graphics drawing request to draw a graph of all the target proportions of each target platform through the Echarts tool to obtain a stacked bar chart, and send the stacked bar chart to the client; the stacked bar chart is used to represent the proportion of target data of all target types corresponding to each target platform to the sum of all the target data.
[0007] A device for determining the proportion of a stacked bar chart based on Echarts, comprising: a data screening module, configured to receive a data collection request, obtain initial data of at least one target type in different target platforms, and screen out target data corresponding to each of the target platforms; the target data refers to the initial data of all target types corresponding to the same target platform; A summation processing module is used to obtain a data proportion request to sum all the target data corresponding to the same target platform to obtain a total sum value corresponding to each target platform; A data proportion module is used to determine the data result of dividing each target data and the total sum value in the same target platform according to a preset precision, and convert each data result into a data proportion as a percentage; the preset precision is used to represent the number of decimal places retained; an allocation processing module, configured to allocate all the data proportions corresponding to the target platforms using a maximum balance method to obtain a target proportion corresponding to each target data in the same target platform; wherein the sum of all the target proportions is 100%; A graphics drawing module is used to receive a graphics drawing request to draw a graph of all the target proportions of each target platform through the Echarts tool to obtain a stacked bar chart, and send the stacked bar chart to the client; the stacked bar chart is used to represent the proportion of target data of all target types corresponding to each target platform to the sum of all the target data.
[0008] A computer device includes a memory, a processor, and computer-readable instructions stored in the memory and executable on the processor. When the processor executes the computer-readable instructions, the method for determining the proportion of stacked bar charts based on Echarts is implemented.
[0009] One or more readable storage media storing computer-readable instructions, which, when executed by one or more processors, enable the one or more processors to execute the above-mentioned method for determining the proportion of stacked bar charts based on Echarts.
[0010] The above-mentioned stacked bar chart proportion determination method, device, equipment and medium based on Echarts implements the screening of target data corresponding to each target platform by obtaining initial data of at least one target type in different target platforms. Through data proportion request and maximum balance method, accurate calculation of each target proportion is achieved, so that the sum of the proportions is equal to 100%. Through the Echarts tool, the drawing of stacked bar charts is achieved, thereby improving the efficiency of stacked bar chart generation and making the data display information more accurate and intuitive. BRIEF DESCRIPTION OF THE DRAWINGS
[0011] In order to more clearly illustrate the technical solutions of the embodiments of the present invention, the following briefly introduces the drawings required for use in the description of the embodiments of the present invention. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative labor.
[0012] Figure 1 This is a flow chart of a method for determining a stacked bar chart proportion based on Echarts in one embodiment of the present invention; Figure 2 This is a flow chart of step S40 of a method for determining a stacked bar chart proportion based on Echarts in one embodiment of the present invention; Figure 3 1 is a schematic structural diagram of a device for determining a proportion of a stacked bar chart based on Echarts in one embodiment of the present invention; Figure 4 is a schematic diagram of a computer device according to an embodiment of the present invention. DETAILED DESCRIPTION
[0013] The following will clearly and completely describe the technical solutions in the embodiments of the present invention in conjunction with the accompanying drawings. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of them. All other embodiments obtained by ordinary technicians in this field based on the embodiments of the present invention without making any creative efforts shall fall within the scope of protection of the present invention.
[0014] The stacked bar chart proportion determination method based on Echarts provided in this embodiment can be applied in a client and server application environment. The client includes but is not limited to various personal computers, laptops, smartphones, tablet computers, and portable wearable devices. The server can be implemented as an independent server or a server cluster consisting of multiple servers.
[0015] In one embodiment, if Figure 1 As shown, a method for determining the proportion of stacked bar charts based on Echarts is provided, comprising the following steps: S10. Receive a data collection request to obtain initial data of at least one target type in different target platforms, and filter out target data corresponding to each target platform; the target data refers to the initial data of all target types corresponding to the same target platform.
[0016] Understandably, a data collection request refers to a request for obtaining initial data of various types on a platform. Initial data refers to the numerical value corresponding to at least one target type on each target platform, obtained through the data collection request. For example, BGC (Brand Generated Content, meaning content created by a brand to promote its products or services) is 100, PGC (Professionally Generated Content, meaning high-quality content produced by professionals or teams, typically with high production values and professionalism) is 420, and UGC (User Generated Content, meaning content created and uploaded to the internet by ordinary users) is 1520. Target data refers to the initial data for all target types corresponding to the same target platform, namely, the numerical values corresponding to BGC, PGC, and UGC on the same target platform.
[0017] Specifically, a data collection request is received. Then, based on the platform and type requirements in the data collection request, initial data corresponding to each target type is collected on the corresponding target platform. Next, all collected initial data is classified, specifically determining the initial data corresponding to each target type on each target platform. This initial data is then identified as the target data corresponding to each target type, thereby filtering out the target data corresponding to each target platform from all initial data. Finally, the target platform, target type, and target data are associated to facilitate determination of the target type and target platform of the target data.
[0018] S20: Obtain a data share request to sum all the target data corresponding to the same target platform to obtain a total sum corresponding to each target platform.
[0019] It can be understood that a data share request is a request for calculating the proportion of each target data in the target platform. The total sum refers to the sum of all target data in the same target platform.
[0020] Specifically, a data share request is obtained. Using the summation requirement in the data share request, all target data corresponding to the same target platform is summed, that is, the target data of all target types on the same target platform is summed to obtain the total summed value corresponding to each target platform. For example, the values corresponding to BGC, PGC, and UGC on Weibo are summed to obtain the total summed value corresponding to the Weibo.
[0021] S30. Determine the data result of dividing each target data in the same target platform by the total sum value according to a preset precision, and convert each data result into a percentage; the preset precision is used to represent the number of decimal places retained.
[0022] As you can understand, the preset precision indicates the number of decimal places retained. The data result is the value obtained by dividing the target data by the total sum while retaining the preset precision. The data percentage refers to the result of converting the data result into a percentage.
[0023] Specifically, the target data corresponding to each target type corresponding to the same target platform are divided by the total sum corresponding to the target platform to obtain the result corresponding to each target type, and the result is retained according to the preset accuracy to obtain the data result. For example, the result of dividing 400 by 2020 is 0.1980198, which is 0.198 with three decimal places. Then, through the preset conversion function, the data result is converted into a percentage of data proportion, so that the data proportion corresponding to each target type on each target platform can be obtained. For example, 0.352 is converted to 35.2%.
[0024] S40. Allocate and process all the data proportions corresponding to the target platforms using the maximum balance method to obtain target proportions corresponding to each target data in the same target platform; wherein the sum of all the target proportions is 100%.
[0025] Understandably, the sum of all target percentages is 100%. The target percentage is the percentage of data assigned to seats plus the percentage of one percent of seats, as well as the percentage of data not assigned to seats.
[0026] Specifically, all data proportions are rounded to obtain initial proportions corresponding to each data proportion. All data proportions are then subjected to remainder processing to obtain remainder proportions corresponding to each data proportion. All initial proportions are summed, and the result is subtracted from 100% to obtain the seats to be allocated. Then, all remainder proportions are compared to obtain a comparison result, and the seats to be allocated are allocated to the larger remainder proportion among all remainder proportions according to the comparison result. For example, if the number of seats to be allocated is one, the seat to be allocated is allocated to the one with the largest remainder proportion. If the number of seats to be allocated is two, the seats to be allocated are allocated to the first two larger remainder proportions among all remainder proportions. Furthermore, after obtaining the seats, a proportion of one percent is added to the initial proportion, and the result is determined as the target proportion, and the other initial proportions corresponding to each remainder proportion that have not been allocated to seats are determined as the target proportion.
[0027] S50. Receive a graphics drawing request to draw a graph of all the target proportions of each target platform using the Echarts tool to obtain a stacked bar chart, and send the stacked bar chart to the client; the stacked bar chart is used to represent the proportion of target data of all target types corresponding to each target platform to the sum of all the target data.
[0028] Understandably, the stacked bar chart is used to represent the ratio of target data of all target types corresponding to each target platform to the sum of all target data.
[0029] Specifically, a graph drawing request is received, and all target proportions, corresponding target types, and corresponding target platforms are input into the Echarts tool. Then, a stacked graph of target data of all target types corresponding to each target platform is drawn on the canvas according to the requirements and parameters in the graph drawing request. In this way, the stacked graphs corresponding to all target platforms are drawn on the canvas to obtain a stacked bar chart, which is then sent to the client for display.
[0030] In this embodiment of the present invention, by obtaining initial data for at least one target type from different target platforms, the target data corresponding to each target platform is screened. By using data percentage requests and the maximum balance method, the percentage of each target is accurately calculated, ensuring that the sum of the percentages equals 100%. Using the Echarts tool, stacked bar charts are created, improving their efficiency and making the data display more accurate and intuitive.
[0031] In one embodiment, step S10, i.e., filtering out target data corresponding to each target platform, includes: S101 , platform classification is performed on all the initial data according to the target platforms corresponding to the initial data, to obtain platform data corresponding to the target platforms.
[0032] S102: Classify all the platform data by target types corresponding to the initial data to obtain target data corresponding to the target types.
[0033] It can be understood that platform data refers to the initial data corresponding to each target platform, and target data refers to the initial data of all target types corresponding to the same target platform.
[0034] Specifically, after obtaining initial data through a data collection request, all initial data is classified according to the target platform, that is, all data from the same platform is grouped into one category to obtain platform data. Furthermore, different platform data from the same target platform are classified by target type, that is, each type of platform data is grouped into one category according to the target type to obtain target data. The above two steps can be interchanged, namely, first filtering out type data of the same target type, and then filtering out target data corresponding to the same target platform from all type data. When obtaining initial data, the target platform and its corresponding target type are also obtained. For example, BGC, PGC, and UGC. BGC data, PGC data, and UGC data from Weibo, WeChat, Douyin, Xiaohongshu, and Bilibili are obtained. Then, using platform classification, the BGC data, PGC data, and UGC data corresponding to each platform are obtained. Then, using type classification, the specific data values corresponding to each type are obtained.
[0035] In this embodiment, the initial data is classified by target platform and target type, thereby achieving screening of platform data and determining specific data values corresponding to each type, thereby achieving screening of target data.
[0036] In one embodiment, if Figure 2 As shown, in step S40, all the data proportions corresponding to the target platforms are allocated using the maximum balance method to obtain the target proportions corresponding to the target data in the same target platform, including: S401, rounding all the data proportions to obtain initial proportions corresponding to the respective data proportions.
[0037] S402, performing difference processing on each of the data proportions and the initial proportions corresponding to each of the data proportions to obtain a remainder proportion corresponding to each of the data proportions.
[0038] S403, allocating seats for the remainder proportions corresponding to the target data of the same target platform by using the maximum balance method, and obtaining allocation quantities corresponding to the remainder proportions.
[0039] S404: Determine a target proportion corresponding to each target data according to the allocated quantity corresponding to the same data proportion and the initial proportion.
[0040] It can be understood that the initial proportion refers to the value before the decimal point in the data proportion of each percentage, for example, 75%, etc. The remainder proportion refers to the value after the decimal point in the data proportion of each percentage, for example, 0.3%, etc.
[0041] Specifically, after converting each data result into a data proportion in percentage, all data proportions are rounded, that is, the values before the decimal point of all data proportions are extracted, and the data is determined as the initial proportion, so that the initial proportion corresponding to each data proportion can be obtained. Then, each data proportion and the initial proportion corresponding to each data proportion are subjected to difference processing, that is, the data proportion and the initial proportion corresponding to the data proportion are subtracted to obtain the remainder proportion corresponding to each initial proportion. Alternatively, the values after the decimal point of all data proportions are extracted, and the data is determined as the remainder proportion. Further, seats are allocated to the remainder proportions corresponding to each initial proportion by the maximum remainder method, that is, the remainder proportion of the allocated seats is calculated by the maximum remainder method, and the allocated quantity corresponding to each remainder proportion is obtained, wherein the allocated quantity is represented as one if a seat is allocated, and the allocated quantity is represented as zero if a seat is not allocated. Finally, the initial proportion corresponding to the same remainder proportion will be increased by one percent through the meaning represented by the allocated number, and the obtained result and the initial proportion not allocated to seats will be determined as the target proportion corresponding to each target data, ensuring that the sum of all target proportions is 100%.
[0042] In this embodiment, the determination of the initial proportion and the determination of the remainder proportion are achieved. The maximum remainder method is used to allocate seats, thereby determining the allocated number and accurately calculating the target proportion.
[0043] In one embodiment, in step S403, seats are allocated for the remainder proportions corresponding to the target data of the same target platform using the maximum balance method to obtain the allocated quantity corresponding to each remainder proportion, including: S4031: Sorting all the remainder proportions corresponding to the same target platform to obtain a sorting result.
[0044] S4032: summing up all the initial proportions corresponding to the same target platform to obtain a summation result, and determining a value to be allocated based on the summation result.
[0045] S4033: Allocate seats to the sorting results and the values to be allocated using a maximum remainder method to obtain allocation quantities corresponding to the proportions of the remainders.
[0046] It is understandable that the sorting result is used to represent the sorting result of all the remainder proportions from large to small or small to large. The value to be allocated refers to the seats to be allocated, that is, the difference between the sum of all initial proportions and 100%.
[0047] Specifically, after obtaining the remainder proportion, all remainder proportions of different target types of the same target platform are compared by the bubble method, and all remainder proportions are sorted by the comparison results to obtain the sorting result. Then, all the initial proportions corresponding to the same target platform are summed up, that is, the initial proportions of all target types of the same target platform are summed up, so as to obtain the summation result corresponding to each target platform, and the summation result and 100% are subtracted to obtain the difference between the summation result and 100%, and the difference is determined as the value to be allocated, so as to obtain the value to be allocated corresponding to each target platform. Further, the seats are allocated to the sorting results and the values to be allocated by the maximum balance method, that is, the values to be allocated are divided into one and allocated to the largest remainder proportion in the sorting results, so as to obtain the allocation quantity corresponding to each remainder proportion. Among them, the allocation quantity of the remainder proportion that is not allocated to a seat is represented as zero. For example, we obtain BGC data, PGC data, and UGC data from Weibo, WeChat, Douyin, Xiaohongshu, and Bilibili. The remainders corresponding to the three target data are 0.3%, 0.6%, and 0.2%, respectively, with initial proportions of 4%, 19%, and 75%. Using the maximum balance method, we determine that 0.7% corresponds to one seat, 0.3% corresponds to one seat, and the allocated number is recorded as one. 0.2% does not receive any seat, and the allocated number is recorded as zero.
[0048] In this embodiment, the sorting results are obtained by sorting all the remainder proportions. The summation of all the initial proportions is obtained, thereby determining the value to be allocated. The seats are allocated by using the maximum remainder method based on the sorting results and the value to be allocated, thereby determining the number of seats to be allocated.
[0049] In one embodiment, in step S404, determining the target proportion corresponding to each target data according to the allocated quantity and the initial proportion corresponding to the same data proportion includes: The initial proportion corresponding to the same remainder proportion is updated by the allocated quantity to obtain the target proportion corresponding to each target data; wherein, the allocated quantity is used to represent whether the seat is allocated, and each seat represents an increase of one percent in the proportion of the initial proportion.
[0050] It can be understood that the allocated number is used to represent whether the seat is allocated, and each seat represents an increase of one percent in the proportion of the initial share.
[0051] Specifically, after obtaining the allocated quantity corresponding to each remainder proportion, the initial proportion corresponding to each remainder proportion is obtained, and the initial proportion is updated by the allocated quantity corresponding to the same remainder proportion. That is, if the fractional quantity corresponding to the remainder proportion indicates that the remainder proportion is allocated to a seat, then the proportion of the initial proportion corresponding to the remainder proportion is increased by 1%, and the target proportion of the target data corresponding to the remainder proportion can be obtained. For example, the remainder proportions corresponding to the three target data are 0.1%, 0.8% and 0.2%, respectively, and the initial proportions are 5%, 19% and 75%. The maximum remainder method is used to determine that 0.8% corresponds to a seat, while 0.1% and 0.2% are not allocated seats. In this way, the initial proportion corresponding to 0.8%, that is, 19%, is increased by 1%, thereby obtaining the target proportion, that is, 20%, and 5% and 75% are determined as the target proportions.
[0052] In this embodiment, the initial proportion is updated by the allocated quantity corresponding to the same remainder proportion, thereby achieving accurate calculation of the target proportion, ensuring that the sum of all target proportions is 100%, and avoiding the poor effect presented in the stacked bar chart when the sum of the proportions is not 100%.
[0053] In one embodiment, in step S50, all the target proportions of each target platform are plotted using the Echarts tool to obtain a stacked bar chart, including: S501: Input all the target proportions, the target types corresponding to the target proportions, and the target platforms corresponding to the target proportions into the Echarts tool.
[0054] S502 : According to the graphics drawing request, determining, in the Echarts tool, a rendering color corresponding to each of the target types, and determining abscissa data and ordinate data corresponding to each of the target platforms.
[0055] S503 : Draw a stacked bar chart according to all the target proportions, all the rendering colors, all the abscissa data, and all the ordinate data.
[0056] Understandably, ECharts tool refers to a visualization tool for generating various interactive charts.
[0057] Specifically, after obtaining the target proportion, all target proportions, the target types corresponding to each target proportion, and the target platforms corresponding to each target proportion are input into the Echarts tool. Then, the rendering color corresponding to each target type is determined through the color rendering requirements in the graphics drawing request, for example, the first target type corresponds to orange, the second target type corresponds to blue, and the third target type corresponds to green. Then, the horizontal coordinate data and the vertical coordinate data corresponding to each target platform are determined through the width requirements and height requirements in the graphics drawing request, and the horizontal coordinate data representation meaning and the vertical coordinate data representation meaning are determined, that is, the coordinate axis representing the target type and the coordinate axis representing the target platform, as well as the corresponding graphic data on each axis. Further, a stacked bar chart is drawn on the canvas according to all target proportions, all rendering colors, all horizontal coordinate data, and all vertical coordinate data, that is, the coordinate axis is first drawn on the canvas through the horizontal coordinate data and the vertical coordinate data, and then the target proportion corresponding to the target type of each target platform is drawn on the coordinate axis with different colors and the same width bar charts, and the numerical value of each target proportion is displayed in the corresponding bar chart. Among them, the height of the bar chart is determined according to the target proportion.
[0058] In this embodiment, the stacked bar chart is drawn using the ECharts tool, thereby improving the efficiency of generating the stacked bar chart. By rendering the color and target percentage display, the data display information is made more accurate and intuitive.
[0059] In one embodiment, step S503, i.e., determining the abscissa data and ordinate data corresponding to each target platform, includes: S5031: Determine the width position of drawing the stacked bar chart on the canvas.
[0060] S5032: Determine the height position of drawing the stacked bar chart on the canvas.
[0061] S5033: Determine the graphic width and graphic height corresponding to each target platform in the stacked bar chart according to the width position and the height position.
[0062] S5034: Determine horizontal coordinate data and vertical coordinate data according to the graphic width and the graphic height.
[0063] It can be understood that the width position includes the width starting position and the width ending position. The ending position includes the height starting position and the height ending position. The graph width refers to the width of the bar graph on the coordinate axis where the target platform is located. The graph height refers to the height of each target type in the bar graph on the coordinate axis where the target proportion is located.
[0064] Specifically, after receiving a graphics drawing request, the width starting and ending positions corresponding to each target platform are determined on either the horizontal or vertical axis using the graphic width and interval values in the graphics drawing request. On another axis corresponding to the target platform, the height starting and ending positions corresponding to each target type in each target platform are determined using the percentage intervals in the graphics drawing request (e.g., intervals from 10% to 100%) and the target percentage of each target type in each target platform. For example, Weibo has 10% BGC, 20% PGC, and 70% UGC. Or, TikTok has 30% BGC, 20% PGC, and 50% UGC. Based on the width starting and ending positions corresponding to each target platform, the width of the graphic corresponding to each target platform on the axis representing the target platform is determined, where the width is the same for all target platforms. Based on the height starting and ending positions corresponding to each target platform, the height of the graphic corresponding to each target percentage in each target platform on the axis representing the percentage is determined. Finally, the values corresponding to the width and height of the graphic are converted into corresponding horizontal coordinate data and vertical coordinate data.
[0065] In this embodiment, the width parameter in the graphics drawing request is used to determine the width position. The height parameter in the graphics drawing request and the proportion of all objects are used to determine the height position, thereby obtaining the width and height of the graphics, and then converting the horizontal and vertical coordinate data, which speeds up the subsequent graphics drawing.
[0066] It should be understood that the size of the serial numbers of the steps in the above embodiments does not mean the order of execution. The execution order of each process should be determined by its function and internal logic, and should not constitute any limitation on the implementation process of the embodiments of the present invention.
[0067] In one embodiment, a stacked bar chart ratio determination device based on Echarts is provided, and the stacked bar chart ratio determination device based on Echarts corresponds to the stacked bar chart ratio determination method based on Echarts in the above embodiment. Figure 3As shown, the stacked bar chart ratio determination device based on Echarts includes a text splicing module 10, a content expansion module 20, a stacked bar chart ratio determination module 30 based on Echarts, and a content evaluation module 40. The functional modules are described in detail as follows: The data screening module 10 is configured to receive a data collection request to obtain initial data of at least one target type in different target platforms, and to screen out target data corresponding to each target platform; the target data refers to the initial data of all target types corresponding to the same target platform; A summation processing module 20 is used to obtain a data proportion request to sum all the target data corresponding to the same target platform to obtain a total sum value corresponding to each target platform; The data proportion module 30 is used to determine the data result of dividing each target data in the same target platform by the total sum according to a preset precision, and convert each data result into a data proportion as a percentage; the preset precision is used to represent the number of decimal places retained; The allocation processing module 40 is configured to allocate all the data proportions corresponding to the target platforms using a maximum balance method to obtain a target proportion corresponding to each target data in the same target platform; wherein the sum of all the target proportions is 100%; The graphics drawing module 50 is used to receive a graphics drawing request to draw a graph of all the target proportions of each target platform through the Echarts tool to obtain a stacked bar chart, and send the stacked bar chart to the client; the stacked bar chart is used to represent the proportion of target data of all target types corresponding to each target platform to the sum of all the target data.
[0068] Optionally, the allocation processing module 40 includes: An initial proportion unit, configured to round all the data proportions to obtain an initial proportion corresponding to each data proportion; A remainder proportion unit is used to perform difference processing on each of the data proportions and the initial proportion corresponding to each of the data proportions to obtain a remainder proportion corresponding to each of the data proportions; an allocation quantity unit, configured to allocate seats to the remainder proportions corresponding to the target data of the same target platform by using a maximum balance method, and obtain allocation quantities corresponding to the remainder proportions; The target proportion unit is used to determine the target proportion corresponding to each target data according to the allocated quantity corresponding to the same data proportion and the initial proportion.
[0069] Optionally, the allocation quantity unit includes: A sorting result subunit is used to sort all the remainder proportions corresponding to the same target platform to obtain a sorting result; a value-to-be-allocated subunit, configured to sum all the initial proportions corresponding to the same target platform to obtain a summation result, and determine a value to be allocated based on the summation result; The seat allocation subunit is used to allocate seats to the sorting results and the values to be allocated by using the maximum remainder method to obtain the allocated quantities corresponding to the proportions of the remainders.
[0070] Optionally, the target proportion unit includes: The summation processing sub-unit is used to update the initial proportion corresponding to the same remainder proportion through the allocated quantity to obtain the target proportion corresponding to each target data; wherein, the allocated quantity is used to represent whether the seat is allocated, and each seat represents an increase of one percent in the proportion of the initial proportion.
[0071] Optionally, the graphics drawing module 50 includes: A data input unit, configured to input all the target proportions, the target types corresponding to the target proportions, and the target platforms corresponding to the target proportions into the Echarts tool; a data determination unit, configured to determine, in the Echarts tool, a rendering color corresponding to each target type and abscissa data and ordinate data corresponding to each target platform according to the graphics drawing request; A bar chart drawing unit is used to draw a stacked bar chart according to all the target proportions, all the rendering colors, all the horizontal coordinate data and all the vertical coordinate data.
[0072] Optionally, the data determination unit includes: The starting position subunit is used to determine the width position of drawing the stacked bar chart on the canvas; The end position subunit is used to determine the height position of drawing the stacked bar chart on the canvas; The platform graphic subunit is configured to determine the graphic width and graphic height corresponding to each target platform in the stacked bar chart according to the width position and the height position; The coordinate data subunit is used to determine the horizontal coordinate data and the vertical coordinate data according to the graphic width and the graphic height.
[0073] Optionally, the data screening module 10 includes: a platform classification unit, configured to perform platform classification on all the initial data according to the target platforms corresponding to the initial data, and obtain platform data corresponding to the target platforms; The type classification unit is used to classify all the platform data by the target type corresponding to each of the initial data to obtain target data corresponding to each of the target types.
[0074] In one embodiment, a computer device is provided. The computer device may be a terminal, and its internal structure diagram may be as follows: Figure 4 As shown. The computer device includes a processor, a memory, a network interface, a display screen and an input device connected via a system bus. The processor of the computer device is used to provide computing and control capabilities. The memory of the computer device includes a readable storage medium and an internal memory. The non-volatile storage medium stores an operating system and computer-readable instructions. The internal memory provides an environment for the operation of the operating system and computer-readable instructions in the readable storage medium. The network interface of the computer device is used to communicate with an external server via a network connection. When the computer-readable instructions are executed by the processor, a method for determining the proportion of a stacked bar chart based on Echarts is implemented. The readable storage medium provided in this embodiment includes a non-volatile readable storage medium and a volatile readable storage medium.
[0075] In one embodiment, a computer device is provided, including a memory, a processor, and computer-readable instructions stored in the memory and executable on the processor. When the processor executes the computer-readable instructions, the method for determining the proportion of stacked bar charts based on Echarts or the method for emotion recognition is implemented.
[0076] In one embodiment, one or more computer-readable storage media storing computer-readable instructions are provided. The computer-readable storage media provided in this embodiment include non-volatile computer-readable storage media and volatile computer-readable storage media. The computer-readable storage media store computer-readable instructions, which, when executed by one or more processors, implement the aforementioned Echarts-based stacked bar chart proportion determination method or the aforementioned emotion recognition method.
[0077] Those skilled in the art will understand that all or part of the processes in the above-mentioned embodiments can be implemented by instructing the relevant hardware through computer-readable instructions. The computer-readable instructions can be stored in a non-volatile readable storage medium or a volatile readable storage medium. When the computer-readable instructions are executed, they can include the processes of the embodiments of the above-mentioned methods. Among them, any reference to memory, storage, database or other media used in the embodiments provided in this application may include non-volatile and / or volatile memory. Non-volatile memory may include read-only memory (ROM), programmable ROM (PROM), electrically programmable ROM (EPROM), electrically erasable programmable ROM (EEPROM) or flash memory. Volatile memory may include random access memory (RAM) or external cache memory. By way of illustration and not limitation, RAM is available in many forms such as static RAM (SRAM), dynamic RAM (DRAM), synchronous DRAM (SDRAM), double data rate SDRAM (DDR SDRAM), enhanced SDRAM (ESDRAM), Synchronous Link DRAM (SLDRAM), Rambus direct RAM (RDRAM), direct memory bus dynamic RAM (DRDRAM), and memory bus dynamic RAM (RDRAM), etc.
[0078] Those skilled in the art will clearly understand that for the sake of convenience and brevity of description, only the division of the above-mentioned functional units and modules is used as an example. In actual applications, the above-mentioned functions can be distributed and completed by different functional units and modules as needed, that is, the internal structure of the device can be divided into different functional units or modules to complete all or part of the functions described above.
[0079] The embodiments described above are only used to illustrate the technical solutions of the present invention, rather than to limit the same. Although the present invention has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or make equivalent replacements for some of the technical features therein. These modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the various embodiments of the present invention, and should all be included in the scope of protection of the present invention.
Claims
1. A method for determining the proportion of stacked bar charts based on Echarts, characterized in that: include: receiving a data collection request to obtain initial data of at least one target type in different target platforms, and filtering out target data corresponding to each of the target platforms; The target data refers to the initial data of all target types corresponding to the same target platform; Obtain a data share request to sum all the target data corresponding to the same target platform to obtain a total sum corresponding to each target platform; Determine the data result of dividing each target data in the same target platform by the total sum value according to a preset precision, and convert each data result into a data proportion as a percentage; the preset precision is used to represent the number of decimal places retained; Allocating all data proportions corresponding to each target platform using the maximum balance method to obtain a target proportion corresponding to each target data in the same target platform; wherein the sum of all target proportions is 100%; Receive a graphics drawing request to draw a graph of all the target proportions of each target platform through the Echarts tool to obtain a stacked bar chart, and send the stacked bar chart to the client; the stacked bar chart is used to represent the proportion of target data of all target types corresponding to each target platform to the sum of all the target data.
2. The method for determining the proportion of stacked bar charts based on Echarts according to claim 1, characterized in that: The method of allocating all data proportions corresponding to the target platforms by the maximum balance method to obtain target proportions corresponding to the target data in the same target platform includes: Rounding off all the data proportions to obtain initial proportions corresponding to the respective data proportions; Performing difference processing on each of the data proportions and the initial proportions corresponding to each of the data proportions to obtain a remainder proportion corresponding to each of the data proportions; Allocating seats for the remainder proportions corresponding to the target data of the same target platform using the maximum balance method to obtain the allocated quantity corresponding to each remainder proportion; The target proportion corresponding to each target data is determined according to the allocated quantity and the initial proportion corresponding to the same data proportion.
3. The method for determining the proportion of stacked bar charts based on Echarts according to claim 2, wherein: The method of allocating seats for the remainder proportions corresponding to the target data of the same target platform by the maximum balance method to obtain the allocated quantity corresponding to each remainder proportion includes: Sorting all the remainder proportions corresponding to the same target platform to obtain a sorting result; Summing all the initial proportions corresponding to the same target platform to obtain a summation result, and determining a value to be allocated based on the summation result; The seats are allocated to the sorting results and the values to be allocated using the maximum remainder method to obtain the allocated quantities corresponding to the proportions of the remainders.
4. The method for determining the proportion of stacked bar charts based on Echarts according to claim 2, wherein: The determining, based on the allocated quantity and the initial proportion corresponding to the same data proportion, the target proportion corresponding to each target data includes: The initial proportion corresponding to the same remainder proportion is updated by the allocated quantity to obtain the target proportion corresponding to each target data; wherein, the allocated quantity is used to represent whether the seat is allocated, and each seat represents an increase of one percent in the proportion of the initial proportion.
5. The method for determining the proportion of stacked bar charts based on Echarts according to claim 1, wherein: The target proportions of all target platforms are graphically plotted using the Echarts tool to obtain a stacked bar chart, including: Input all the target proportions, the target types corresponding to the target proportions, and the target platforms corresponding to the target proportions into the Echarts tool; According to the graphics drawing request, determining, in the Echarts tool, a rendering color corresponding to each of the target types, and determining abscissa data and ordinate data corresponding to each of the target platforms; A stacked bar chart is drawn according to all the target proportions, all the rendering colors, all the abscissa data, and all the ordinate data.
6. The method for determining the proportion of stacked bar charts based on Echarts according to claim 5, characterized in that: The determining of the horizontal coordinate data and the vertical coordinate data corresponding to each of the target platforms includes: Determine the width and position of the stacked bar chart on the canvas; Determine the height position of drawing the stacked bar chart on the canvas; Determining the graphic width and graphic height corresponding to each target platform in the stacked bar chart according to the width position and the height position; The horizontal coordinate data and the vertical coordinate data are determined according to the graphic width and the graphic height.
7. The method for determining the proportion of stacked bar charts based on Echarts according to claim 1, characterized in that: The step of filtering out target data corresponding to each target platform includes: Performing platform classification on all the initial data according to the target platform corresponding to each of the initial data to obtain platform data corresponding to each of the target platforms; All the platform data are classified by target types corresponding to the initial data to obtain target data corresponding to the target types.
8. A stacked bar chart proportion determination device based on Echarts, characterized in that: include: a data screening module, configured to receive a data collection request, obtain initial data of at least one target type in different target platforms, and screen out target data corresponding to each of the target platforms; the target data refers to the initial data of all target types corresponding to the same target platform; A summation processing module is used to obtain a data proportion request to sum all the target data corresponding to the same target platform to obtain a total sum value corresponding to each target platform; A data proportion module is used to determine the data result of dividing each target data and the total sum value in the same target platform according to a preset precision, and convert each data result into a data proportion as a percentage; the preset precision is used to represent the number of decimal places retained; an allocation processing module, configured to allocate all the data proportions corresponding to the target platforms using a maximum balance method to obtain a target proportion corresponding to each target data in the same target platform; wherein the sum of all the target proportions is 100%; A graphics drawing module is used to receive a graphics drawing request to draw a graph of all the target proportions of each target platform through the Echarts tool to obtain a stacked bar chart, and send the stacked bar chart to the client; the stacked bar chart is used to represent the proportion of target data of all target types corresponding to each target platform to the sum of all the target data.
9. A computer device comprising a memory, a processor, and computer-readable instructions stored in the memory and executable on the processor, wherein: When the processor executes the computer-readable instructions, the method for determining the proportion of a stacked bar chart based on Echarts according to any one of claims 1 to 7 is implemented.
10. One or more computer-readable storage media storing computer-readable instructions, characterized in that: When the computer-readable instructions are executed by one or more processors, the one or more processors are caused to execute the method for determining the proportion of a stacked bar chart based on Echarts as described in any one of claims 1 to 7.