在 AmCharts 中为类别轴创建自定义气球文本
Creating custom balloon text for category Axis in AmCharts
我在我的 AngularJs 应用程序中使用 AmCharts,我想知道当我们将鼠标悬停在类别轴标签上时如何创建自定义气球文本。以下是我的代码:
var configChart = function () {
employeeChart = new AmCharts.AmSerialChart();
employeeChart.categoryField = "empId";
var yAxis = new AmCharts.ValueAxis();
yAxis.position = "left";
employeeChart.addValueAxis(yAxis);
mcfBarGraph = new AmCharts.AmGraph();
mcfBarGraph.valueField = "employeeRating";
mcfBarGraph.type = "column";
mcfBarGraph.fillAlphas = 1;
mcfBarGraph.lineColor = "#f0ab00";
mcfBarGraph.valueAxis = yAxis;
employeeChart.addGraph(empBarGraph);
employeeChart.write('employee');
}
在我的图表中,类别字段是 emp Id,valueField 是评分。此图表的数据提供者是员工 json 数据。现在 JSON 中多了一个属性,即位置。所以我想在图表上的类别轴字段上显示 "Location-Emp ID"。
你能告诉我如何实现这个功能吗?
这似乎与 another question you recently asked 非常相似。
对于 categoryAxis 标签上的气球,您想为图表设置一个 chartCursor,然后在该对象上设置一个 categoryBalloonFunction:
var chartCursor = new AmCharts.ChartCursor();
chartCursor.categoryBalloonFunction = function(category) {
return location + "-" + category;
};
employeeChart.addChartCursor(chartCursor);
如何解析 angular 中的位置变量由您决定。如果您可以提供 mvce 形式的 fidddle 或 codepen 来重现您的场景,那么对于如何处理您的情况将需要大量猜测。
我在我的 AngularJs 应用程序中使用 AmCharts,我想知道当我们将鼠标悬停在类别轴标签上时如何创建自定义气球文本。以下是我的代码:
var configChart = function () {
employeeChart = new AmCharts.AmSerialChart();
employeeChart.categoryField = "empId";
var yAxis = new AmCharts.ValueAxis();
yAxis.position = "left";
employeeChart.addValueAxis(yAxis);
mcfBarGraph = new AmCharts.AmGraph();
mcfBarGraph.valueField = "employeeRating";
mcfBarGraph.type = "column";
mcfBarGraph.fillAlphas = 1;
mcfBarGraph.lineColor = "#f0ab00";
mcfBarGraph.valueAxis = yAxis;
employeeChart.addGraph(empBarGraph);
employeeChart.write('employee');
}
在我的图表中,类别字段是 emp Id,valueField 是评分。此图表的数据提供者是员工 json 数据。现在 JSON 中多了一个属性,即位置。所以我想在图表上的类别轴字段上显示 "Location-Emp ID"。
你能告诉我如何实现这个功能吗?
这似乎与 another question you recently asked 非常相似。
对于 categoryAxis 标签上的气球,您想为图表设置一个 chartCursor,然后在该对象上设置一个 categoryBalloonFunction:
var chartCursor = new AmCharts.ChartCursor();
chartCursor.categoryBalloonFunction = function(category) {
return location + "-" + category;
};
employeeChart.addChartCursor(chartCursor);
如何解析 angular 中的位置变量由您决定。如果您可以提供 mvce 形式的 fidddle 或 codepen 来重现您的场景,那么对于如何处理您的情况将需要大量猜测。