| 12 | using namespace xg::scale; |
| 13 | |
| 14 | std::string AbstractScale::GetTickText(const nlohmann::json &item, XChart *chart, std::size_t index) { |
| 15 | if(!this->tickCallbackId.empty() && chart) { |
| 16 | nlohmann::json content{{"content", item}}; |
| 17 | auto rst = xg::json::ParseString((chart->InvokeFunction(this->tickCallbackId, content.dump()))); |
| 18 | if(rst.is_object() && rst.contains("content")) { |
| 19 | return rst["content"]; |
| 20 | } |
| 21 | } |
| 22 | |
| 23 | if(item.is_string()) { |
| 24 | return item.get<std::string>(); |
| 25 | } else if(item.is_number()) { |
| 26 | return std::to_string(item.get<int>()); |
| 27 | } else { |
| 28 | return ""; // TODO get Tick text from callback |
| 29 | } |
| 30 | } |
no test coverage detected