| 1 | package opts |
| 2 | |
| 3 | import "github.com/go-echarts/go-echarts/v2/types" |
| 4 | |
| 5 | // Tooltip is the option set for a tooltip component. |
| 6 | // https://echarts.apache.org/en/option.html#tooltip |
| 7 | type Tooltip struct { |
| 8 | // Whether to show the tooltip component, including tooltip floating layer and axisPointer. |
| 9 | Show types.Bool `json:"show,omitempty"` |
| 10 | |
| 11 | // Type of triggering. |
| 12 | // Options: |
| 13 | // * 'item': Triggered by data item, which is mainly used for charts that |
| 14 | // don't have a category axis like scatter charts or pie charts. |
| 15 | // * 'axis': Triggered by axes, which is mainly used for charts that have category axes, |
| 16 | // like bar charts or line charts. |
| 17 | // * 'none': Trigger nothing. |
| 18 | Trigger string `json:"trigger,omitempty"` |
| 19 | |
| 20 | // Conditions to trigger tooltip. Options: |
| 21 | // * 'mousemove': Trigger when mouse moves. |
| 22 | // * 'click': Trigger when mouse clicks. |
| 23 | // * 'mousemove|click': Trigger when mouse clicks and moves. |
| 24 | // * 'none': Do not triggered by 'mousemove' and 'click'. Tooltip can be triggered and hidden |
| 25 | // manually by calling action.tooltip.showTip and action.tooltip.hideTip. |
| 26 | // It can also be triggered by axisPointer.handle in this case. |
| 27 | TriggerOn string `json:"triggerOn,omitempty"` |
| 28 | |
| 29 | // Whether mouse is allowed to enter the floating layer of tooltip, whose default value is false. |
| 30 | // If you need to interact in the tooltip like with links or buttons, it can be set as true. |
| 31 | Enterable types.Bool `json:"enterable,omitempty"` |
| 32 | |
| 33 | // The content formatter of tooltip's floating layer which supports string template and callback function. |
| 34 | // |
| 35 | // 1. String template |
| 36 | // The template variables are {a}, {b}, {c}, {d} and {e}, which stands for series name, |
| 37 | // data name and data value and ect. When trigger is set to be 'axis', there may be data from multiple series. |
| 38 | // In this time, series index can be refereed as {a0}, {a1}, or {a2}. |
| 39 | // {a}, {b}, {c}, {d} have different meanings for different series types: |
| 40 | // |
| 41 | // * Line (area) charts, bar (column) charts, K charts: {a} for series name, |
| 42 | // {b} for category name, {c} for data value, {d} for none; |
| 43 | // * Scatter (bubble) charts: {a} for series name, {b} for data name, {c} for data value, {d} for none; |
| 44 | // * Map: {a} for series name, {b} for area name, {c} for merging data, {d} for none; |
| 45 | // * Pie charts, gauge charts, funnel charts: {a} for series name, {b} for data item name, |
| 46 | // {c} for data value, {d} for percentage. |
| 47 | // |
| 48 | // 2. Callback function |
| 49 | // The format of callback function: |
| 50 | // (params: Object|Array, ticket: string, callback: (ticket: string, html: string)) => string |
| 51 | // The first parameter params is the data that the formatter needs. Its format is shown as follows: |
| 52 | // { |
| 53 | // componentType: 'series', |
| 54 | // // Series type |
| 55 | // seriesType: string, |
| 56 | // // Series index in option.series |
| 57 | // seriesIndex: number, |
| 58 | // // Series name |
| 59 | // seriesName: string, |
| 60 | // // Data name, or category name |
| 61 | // name: string, |
| 62 | // // Data index in input data array |
| 63 | // dataIndex: number, |
| 64 | // // Original data as input |
| 65 | // data: Object, |
| 66 | // // Value of data. In most series it is the same as data. |
| 67 | // // But in some series it is some part of the data (e.g., in map, radar) |
| 68 | // value: number|Array|Object, |
| 69 | // // encoding info of coordinate system |
| 70 | // // Key: coord, like ('x' 'y' 'radius' 'angle') |
| 71 | // // value: Must be an array, not null/undefined. Contain dimension indices, like: |
| 72 | // // { |
| 73 | // // x: [2] // values on dimension index 2 are mapped to x axis. |
| 74 | // // y: [0] // values on dimension index 0 are mapped to y axis. |
| 75 | // // } |
| 76 | // encode: Object, |
| 77 | // // dimension names list |
| 78 | // dimensionNames: Array<String>, |
| 79 | // // data dimension index, for example 0 or 1 or 2 ... |
| 80 | // // Only work in `radar` series. |
| 81 | // dimensionIndex: number, |
| 82 | // // Color of data |
| 83 | // color: string, |
| 84 | // |
| 85 | // // the percentage of pie chart |
| 86 | // percent: number, |
| 87 | // } |
| 88 | Formatter types.FuncStr `json:"formatter,omitempty"` |
| 89 | |
| 90 | // ValueFormatter Callback function for formatting the value section in tooltip. |
| 91 | // valueFormatter: (value) => '$' + value.toFixed(2) |
| 92 | ValueFormatter types.FuncStr `json:"valueFormatter,omitempty"` |
| 93 | |
| 94 | // The content formatter of tooltip's floating layer which supports string template and callback function. |
| 95 | // See https://echarts.apache.org/en/option.html#grid.tooltip.position |
| 96 | // May be a string ("inside", "top", "bottom", "left", "right") or a function of form: |
| 97 | // (point: Array, params: Object|Array.<Object>, dom: HTMLDomElement, rect: Object, size: Object) => Array |
| 98 | Position types.FuncStr `json:"position,omitempty"` |
| 99 | |
| 100 | // The border color of tooltip's floating layer. |
| 101 | BorderColor string `json:"borderColor,omitempty"` |
| 102 | |
| 103 | // The background color of tooltip's floating layer. e.g. 'rgba(50,50,50,0.7)' |
| 104 | BackgroundColor string `json:"backgroundColor,omitempty"` |
| 105 | |
| 106 | // Configuration item for axisPointer |
| 107 | AxisPointer *AxisPointer `json:"axisPointer,omitempty"` |
| 108 | } |