| 155 | } |
| 156 | |
| 157 | void ChartBridge::CompatToolTip(BridgeCallback callback) { |
| 158 | if (!needToolTip_) { |
| 159 | return; |
| 160 | } |
| 161 | |
| 162 | nlohmann::json tooltip; |
| 163 | auto onPress = BridgeChannel::Callback([callback, this](const std::string &functionId, const std::string ¶ms)-> const std::string { |
| 164 | auto config = json::ParseString(params); |
| 165 | auto &tooltip = json::GetArray(config, "tooltip"); |
| 166 | auto &tooltips = json::GetArray(config, "tooltips"); |
| 167 | callback(nlohmann::json({{"method","render"}, {"tooltip", tooltip.dump()}, {"tooltips", tooltips.dump()}}).dump()); |
| 168 | return params; |
| 169 | }); |
| 170 | |
| 171 | auto onPressEnd = BridgeChannel::Callback([callback, this](const std::string &functionId, const std::string ¶ms)-> const std::string { |
| 172 | auto config = json::ParseString(params); |
| 173 | auto &tooltip = json::GetArray(config, "tooltip"); |
| 174 | callback(nlohmann::json({{"method","render"}, {"tooltipEnd", tooltip.dump()}}).dump()); |
| 175 | return params; |
| 176 | }); |
| 177 | |
| 178 | tooltip["onPress"] = onPress.functionId; |
| 179 | tooltip["onPressEnd"] = onPressEnd.functionId; |
| 180 | callbackFunctions_[onPress.functionId] = std::move(onPress); |
| 181 | callbackFunctions_[onPressEnd.functionId] = std::move(onPressEnd); |
| 182 | |
| 183 | chart_->PatchTooltipsObject(tooltip); |
| 184 | } |
| 185 | |
| 186 | void ChartBridge::CompatScales(const nlohmann::json &dsl) { |
| 187 | //解析scales |
nothing calls this directly
no test coverage detected