| 1 | package opts |
| 2 | |
| 3 | import "github.com/go-echarts/go-echarts/v2/types" |
| 4 | |
| 5 | // Legend is the option set for a legend component. |
| 6 | // Legend component shows symbol, color and name of different series. You can click legends to toggle displaying series in the chart. |
| 7 | // https://echarts.apache.org/en/option.html#legend |
| 8 | type Legend struct { |
| 9 | // Type of legend. Optional values: |
| 10 | // "plain": Simple legend. (default) |
| 11 | // "scroll": Scrollable legend. It helps when too many legend items needed to be shown. |
| 12 | Type string `json:"type,omitempty"` |
| 13 | |
| 14 | // Whether to show the Legend, default true. |
| 15 | // Once you set other options, need to manually set it to true |
| 16 | Show types.Bool `json:"show,omitempty"` |
| 17 | |
| 18 | // Distance between legend component and the left side of the container. |
| 19 | // left value can be instant pixel value like 20; it can also be a percentage |
| 20 | // value relative to container width like '20%'; and it can also be 'left', 'center', or 'right'. |
| 21 | // If the left value is set to be 'left', 'center', or 'right', then the component |
| 22 | // will be aligned automatically based on position. |
| 23 | Left string `json:"left,omitempty"` |
| 24 | |
| 25 | // Distance between legend component and the top side of the container. |
| 26 | // top value can be instant pixel value like 20; it can also be a percentage |
| 27 | // value relative to container width like '20%'; and it can also be 'top', 'middle', or 'bottom'. |
| 28 | // If the left value is set to be 'top', 'middle', or 'bottom', then the component |
| 29 | // will be aligned automatically based on position. |
| 30 | Top string `json:"top,omitempty"` |
| 31 | |
| 32 | // Distance between legend component and the right side of the container. |
| 33 | // right value can be instant pixel value like 20; it can also be a percentage |
| 34 | // value relative to container width like '20%'. |
| 35 | // Adaptive by default. |
| 36 | Right string `json:"right,omitempty"` |
| 37 | |
| 38 | // Distance between legend component and the bottom side of the container. |
| 39 | // bottom value can be instant pixel value like 20; it can also be a percentage |
| 40 | // value relative to container width like '20%'. |
| 41 | // Adaptive by default. |
| 42 | Bottom string `json:"bottom,omitempty"` |
| 43 | |
| 44 | // Width of legend component. Adaptive by default. |
| 45 | Width string `json:"width,omitempty"` |
| 46 | |
| 47 | // Height of legend component. Adaptive by default. |
| 48 | Height string `json:"height,omitempty"` |
| 49 | |
| 50 | // The layout orientation of legend. |
| 51 | // Options: 'horizontal', 'vertical' |
| 52 | Orient string `json:"orient,omitempty"` |
| 53 | |
| 54 | // Legend marker and text aligning. |
| 55 | // By default, it automatically calculates from component location and orientation. |
| 56 | // When left value of this component is 'right' and orient is 'vertical', it would be aligned to 'right'. |
| 57 | // Options: auto/left/right |
| 58 | Align string `json:"align,omitempty"` |
| 59 | |
| 60 | // Legend space around content. The unit is px. |
| 61 | // Default values for each position are 5. |
| 62 | // And they can be set to different values with left, right, top, and bottom. |
| 63 | // Examples: |
| 64 | // 1. Set padding to be 5 |
| 65 | // padding: 5 |
| 66 | // 2. Set the top and bottom paddings to be 5, and left and right paddings to be 10 |
| 67 | // padding: [5, 10] |
| 68 | // 3. Set each of the four paddings separately |
| 69 | // padding: [ |
| 70 | // 5, // up |
| 71 | // 10, // right |
| 72 | // 5, // down |
| 73 | // 10, // left |
| 74 | // ] |
| 75 | Padding interface{} `json:"padding,omitempty"` |
| 76 | |
| 77 | // Formatter is used to format label of legend, which supports string template and callback function. |
| 78 | // Example: |
| 79 | // |
| 80 | // using string template, the template variable is legend name {name} |
| 81 | // formatter: 'Legend {name}' |
| 82 | // using callback function |
| 83 | // formatter: function (name) { |
| 84 | // return 'Legend ' + name; |
| 85 | // } |
| 86 | Formatter types.FuncStr `json:"formatter,omitempty"` |
| 87 | |
| 88 | // Selected mode of legend, which controls whether series can be toggled displaying by clicking legends. |
| 89 | // It is enabled by default, and you may set it to be false to disabled it. |
| 90 | // Besides, it can be set to 'single' or 'multiple', for single selection and multiple selection. |
| 91 | SelectedMode string `json:"selectedMode,omitempty"` |
| 92 | |
| 93 | // Icon of the legend items. |
| 94 | // Icon types provided by ECharts includes |
| 95 | // 'circle', 'rect', 'roundRect', 'triangle', 'diamond', 'pin', 'arrow', 'none' |
| 96 | // It can be set to an image with 'image://url' , in which URL is the link to an image, or dataURI of an image. |
| 97 | // An image URL example: |
| 98 | // 'image://http://example.website/a/b.png' |
| 99 | // A dataURI example: |
| 100 | // |
| 101 | // 'image://data:image/gif;base64,KOY......' |
| 102 | // Icons can be set to arbitrary vector path via 'path://' in ECharts. |
| 103 | // As compared with a raster image, vector paths prevent jagging and blurring when scaled, and have better control over changing colors. |
| 104 | // For example: |
| 105 | // |
| 106 | // 'path://M30.9,53.2C16.8,...' |
| 107 | Icon string `json:"icon,omitempty"` |
| 108 | |
| 109 | // Data array of legend. An array item is usually a name representing string. |
| 110 | // set Data as []string{} if you wants to hide the legend. |
| 111 | Data interface{} `json:"data,omitempty"` |
| 112 | |
| 113 | // Legend color when not selected. |
| 114 | InactiveColor string `json:"inactiveColor,omitempty"` |
| 115 | |
| 116 | // State table of selected legend. |
| 117 | // example: |
| 118 | // var selected = map[string]bool{} |
| 119 | // selected["series1"] = true |
| 120 | // selected["series2"] = false |
| 121 | Selected map[string]bool `json:"selected,omitempty"` |
| 122 | |
| 123 | // Image width of legend symbol. |
| 124 | ItemWidth int `json:"itemWidth,omitempty"` |
| 125 | |
| 126 | // Image height of legend symbol. |
| 127 | ItemHeight int `json:"itemHeight,omitempty"` |
| 128 | |
| 129 | // Legend X position, right/left/center |
| 130 | X string `json:"x,omitempty"` |
| 131 | |
| 132 | // Legend Y position, right/left/center |
| 133 | Y string `json:"y,omitempty"` |
| 134 | |
| 135 | // Legend text style. |
| 136 | TextStyle *TextStyle `json:"textStyle,omitempty"` |
| 137 | |
| 138 | // ItemStyle item style. |
| 139 | ItemStyle *ItemStyle `json:"itemStyle,omitempty"` |
| 140 | } |