英文:
How to convert a ordinal color to linear color heatmap in Anychart?
问题
今天我试图在Android Studio中使用Anychart库创建一个2D热图图表。我无法将ordinalcolor转换为linearcolor。有人能帮帮我吗?
简要信息:
在Android Studio中设置gradle:
allprojects {
repositories {
google()
jcenter()
maven { url 'https://jitpack.io' }
}
}
dependencies {
implementation 'com.android.support:multidex:1.0.3'
implementation 'com.github.AnyChart:AnyChart-Android:1.1.2'
}
热图创建:
HeatMap heatmaps = AnyChart.heatMap();
List<DataEntry> data = new ArrayList<>();
热图数据条目:
for (int i = 0; i < 1; i++) {
for (int j = 0; j < nx; j++) {
for (int k = 0; k < nx; k++) {
data.add(new HeatDataEntry(j + "", k + "", Pressure[i][j][k]));
}
}
}
最终图表:
String[] strArray3 = {"#90caf9", "#ffb74d", "#d84315"};
heatmaps.colorScale().colors(strArray3);
heatmaps.data(data);
AnyChartView anyChartView = (AnyChartView) findViewById(R.id.any_chart_view);
anyChartView.setChart(heatmaps);
如何去掉每个颜色块之间的白色空格?
感谢您的帮助。
完整代码:
int nx = 100;
int[][][] Pressure = new int[1][nx][nx];
for (int i = 0; i < 1; i++) {
for (int j = 0; j < nx; j++) {
for (int k = 0; k < nx; k++) {
Pressure[i][j][k] = 50;
}
}
}
for (int i = 0; i < 1; i++) {
for (int j = nx / 2 - 5; j <= nx / 2 + 5; j++) {
for (int k = nx / 2 - 5; k <= nx / 2 + 5; k++) {
Pressure[i][j][k] = 20;
}
}
}
for (int i = 0; i < 1; i++) {
for (int j = nx / 2 - 3; j <= nx / 2 + 3; j++) {
for (int k = nx / 2 - 3; k <= nx / 2 + 3; k++) {
Pressure[i][j][k] = 2;
}
}
}
HeatMap heatmaps = AnyChart.heatMap();
List<DataEntry> data = new ArrayList<>();
for (int i = 0; i < 1; i++) {
for (int j = 0; j < nx; j++) {
for (int k = 0; k < nx; k++) {
data.add(new HeatDataEntry(j + "", k + "", Pressure[i][j][k]));
}
}
}
String[] strArray3 = {"#90caf9", "#ffb74d", "#d84315"};
heatmaps.colorScale().colors(strArray3);
heatmaps.data(data);
AnyChartView anyChartView = (AnyChartView) findViewById(R.id.any_chart_view);
anyChartView.setChart(heatmaps);
英文:
Today I was trying to create a 2d heatmap plot using Anychart libraries in android studio. I am unable to convert ordinalcolor to linearcolor. Can someone please help me on this.
Short info:
Setting up the gradle in Android studio:
allprojects {
repositories {
google()
jcenter()
maven { url 'https://jitpack.io' }
}
}
dependencies {
implementation 'com.android.support:multidex:1.0.3'
implementation 'com.github.AnyChart:AnyChart-Android:1.1.2'
Heatmap creation:
HeatMap heatmaps = AnyChart.heatMap();
List<DataEntry> data = new ArrayList<>();
Heatmap data Entry:
for (int i = 0; i < 1; i++) {
for (int j = 0; j < nx; j++) {
for (int k = 0; k < nx; k++) {
data.add(new HeatDataEntry(j + "", k + "", Pressure[i][j][k]));
}
}
}
Final plot:
String[] strArray3 = {"#90caf9", "#ffb74d", "#d84315"};
heatmaps.colorScale().colors(strArray3);
heatmaps.data(data);
AnyChartView anyChartView = (AnyChartView) findViewById(R.id.any_chart_view);
anyChartView.setChart(heatmaps);
How can i get rid of the white spaces between each color block?
Thank you for your help.
Complete code:
int nx=100;
int[][][] Pressure=new int[1][nx][nx];
for (int i=0;i<1;i++) {
for (int j=0;j<nx;j++) {
for (int k=0;k<nx;k++) {
Pressure[i][j][k] = 50;
}
}
}
for (int i=0;i<1;i++) {
for (int j=nx/2-5;j<=nx/2+5;j++) {
for (int k=nx/2-5;k<=nx/2+5;k++) {
Pressure[i][j][k] = 20;
}
}
}
for (int i=0;i<1;i++) {
for (int j=nx/2-3;j<=nx/2+3;j++) {
for (int k=nx/2-3;k<=nx/2+3;k++) {
Pressure[i][j][k] = 2;
}
}
}
HeatMap heatmaps = AnyChart.heatMap();
List<DataEntry> data = new ArrayList<>();
for (int i = 0; i < 1; i++) {
for (int j = 0; j < nx; j++) {
for (int k = 0; k < nx; k++) {
data.add(new HeatDataEntry(j + "", k + "", Pressure[i][j][k]));
}
}
}
String[] strArray3 = {"#90caf9", "#ffb74d", "#d84315"};
heatmaps.colorScale().colors(strArray3);
heatmaps.data(data);
AnyChartView anyChartView = (AnyChartView) findViewById(R.id.any_chart_view);
anyChartView.setChart(heatmaps);
答案1
得分: 0
目前 Anychart 不具备在热力图中使用线性颜色的功能,因此我们可以使用以下代码来实现:
HeatMap heatmaps = AnyChart.heatMap();
heatmaps.stroke("none");
以去除颜色之间的白色描边。
来源:Anychart 支持部门
英文:
Currently Anychart does not have the capability to use linear color in Heat map so we can use,
HeatMap heatmaps = AnyChart.heatMap();
heatmaps.stroke("none");
To remove the white strokes between the colors.
Source: Anychart support
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论