echarts 地图图
效果如下图:


1、下载echarts对应包:
2、前端页面:
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<title></title> </head>
<body>
<div id="main" style="height:760px;"></div>
<script src="../Resource/js/jquery-1.8.2.js"></script>
<script src="../Resource/echarts-2.2.7/build/source/echarts-all.js"></script>
<script type="text/javascript"> var myChart = echarts.init(document.getElementById('main'));
var option = {
title: {
text: 'iphone销量',
subtext: '测试数据',
x: 'center'
},
tooltip: {
trigger: 'item'
},
legend: {
orient: 'vertical',
x: 'left',
data: ['iphone3', 'iphone4', 'iphone5','iphone6', 'iphone7']
},
dataRange: {
min: 0,
max: 25000,
x: 'left',
y: 'bottom',
text: ['高', '低'],
calculable: true
},
series: [
{
name: 'iphone3',
type: 'map',
mapType: 'china',
roam: false,
itemStyle: {
normal: { label: { show: true } },
emphasis: { label: { show: true } }
},
data: []
},
{
name: 'iphone4',
type: 'map',
mapType: 'china',
itemStyle: {
normal: { label: { show: true } },
emphasis: { label: { show: true } }
},
data: []
},
{
name: 'iphone5',
type: 'map',
mapType: 'china',
itemStyle: {
normal: { label: { show: true } },
emphasis: { label: { show: true } }
},
data: []
},
{
name: 'iphone6',
type: 'map',
mapType: 'china',
itemStyle: {
normal: { label: { show: true } },
emphasis: { label: { show: true } }
},
data: []
},
{
name: 'iphone7',
type: 'map',
mapType: 'china',
itemStyle: {
normal: { label: { show: true } },
emphasis: { label: { show: true } }
},
data: []
} ]
};
$.get("/Demo/GetData").done(function (data) {
option.series[0].data = data.Iphone3;
option.series[1].data = data.Iphone4;
option.series[2].data = data.Iphone5;
option.series[3].data = data.Iphone6;
option.series[4].data = data.Iphone7;
myChart.setOption(option);
}); </script>
</body>
</html>
3、后台:
1)Model-1
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks; namespace Test.One.Model
{
public class CityModel
{
public string name { get; set; } public int value { get; set; }
}
}
Model-2
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks; namespace Test.One.Model
{
public class IphoneDataModel
{
public List<CityModel> Iphone3 { get;set; } public List<CityModel> Iphone4 { get; set; } public List<CityModel> Iphone5 { get; set; } public List<CityModel> Iphone6 { get; set; } public List<CityModel> Iphone7 { get; set; }
}
}
2)Action:
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Web.Http;
using Test.One.Model;
using Newtonsoft.Json;
using System.Web.Http.Results; namespace Test.One.Apis
{ /// <summary>
/// Demo
/// </summary>
[RoutePrefix("Demo")]
public class DemoController:ApiController
{ private Random r = new Random();
private int Total = ; /// <summary>
///
/// </summary>
/// <returns></returns>
[HttpGet, Route("GetData")]
public JsonResult<IphoneDataModel> GetData()
{ string filePath = System.Web.Hosting.HostingEnvironment.MapPath("/Resource/City/data.txt");
string[] datas = File.ReadAllLines(filePath); int len = r.Next(,datas.Length); IphoneDataModel iphoneDataModel = new IphoneDataModel() {
Iphone3 = new List<CityModel>(),
Iphone4 = new List<CityModel>(),
Iphone5 = new List<CityModel>(),
Iphone6 = new List<CityModel>(),
Iphone7 = new List<CityModel>()
}; List<CityModel> citys = new List<CityModel>();
for (int i = ; i < datas.Length; i++)
{
iphoneDataModel.Iphone3.Add(new CityModel()
{
name = datas[i],
value = r.Next(Total)
});
} for (int i = ; i < len; i++)
{
iphoneDataModel.Iphone4.Add(new CityModel()
{
name = datas[i],
value = r.Next(Total)
});
}
int size = r.Next(,datas.Length); for (int i = ; i < size; i++)
{
iphoneDataModel.Iphone5.Add(new CityModel()
{
name = datas[i],
value = r.Next(Total)
});
} int i6Size = r.Next(, datas.Length); for (int i = ; i < i6Size; i++)
{
iphoneDataModel.Iphone6.Add(new CityModel()
{
name = datas[i],
value = r.Next(Total)
});
} int i7Size = r.Next(, datas.Length); for (int i = ; i < i7Size; i++)
{
iphoneDataModel.Iphone7.Add(new CityModel()
{
name = datas[i],
value = r.Next(Total)
});
}
return Json<IphoneDataModel>(iphoneDataModel);
}
}
}
3)data.txt数据:
北京
天津
上海
重庆
河北
河南
云南
辽宁
黑龙江
湖南
安徽
山东
新疆
江苏
浙江
江西
湖北
广西
甘肃
山西
内蒙古
陕西
吉林
福建
贵州
广东
青海
西藏
四川
宁夏
海南
台湾
香港
澳门
echarts 地图图的更多相关文章
- Echarts 地图(map)插件之 鼠标HOVER和tooltip自定义数据
在项目开发中,有需要用到地图的地方,百度的echarts地图插件就是个不错的选择, 这里总结一下地图自定义鼠标HOVER时的事件和自定义tooltip数据: 一.鼠标HOVER时的事件: 参照官方文档 ...
- 本周学习总结(原生+Echarts地图)
本周主要想完成工作中大屏地图相关的知识,所以学习的时间不是很长 dsa.js(数据结构) 拖了两个星期还没看,等啥时候继续研究算法和数据结构再看源码 GoJS 有时间要好好研究下 https://gi ...
- echarts迁徙图
前段时间在echarts社区,看见别人写的echarts迁徙图,学习并也写了一个 预览地址: https://gallery.echartsjs.com/editor.html?c=xYS-YtzOa ...
- echarts雷达图
用echarts展现雷达图的定制 <!doctype html> <html> <head> <meta charset="utf-8"& ...
- echarts柱图自定义为硬币堆叠的形式
看这标题,可能会有一些人不太明白,那么直接上图,就是柱图展示形式如下图(兼容IE8) 要想实现这样展示效果.我们想用echarts直接实现不行的,即使是纹理填充也不可行的,但是我们可以借助echart ...
- 实现Echarts折线图的虚实转换
需求:医院的体温单,在统计体温时,对于正常情况下统计的体温数据,需要显示实线:对于进行物理降温后统计的体温数据,需要显示虚线. 现有的体温单是运用 Echarts 折线图,统一用实线显示.因此在这基础 ...
- 使用echarts水球图
使用echarts水球图 官方实例中没有水球图样式,当我们需要用到水球图的时候需要下载echarts-liquidfill.js. 使用 在echarts之后引入 echarts-liquidfill ...
- Echarts 地图添加自定义区域
使用 Echarts 生成地图时,如果需要添加一些自定义区域,该怎么做呢?请看下面示例. 生成原始地图 index.hmtl 引入 Jquery 和 Echart <!DOCTYPE html& ...
- Echarts 地图上显示数值
Echarts 地图上展示数值,效果如下: 上代码:关键代码用红色 series: [ { //name: '香港18区人口密度', type: 'map', mapType: 'jiangsu', ...
随机推荐
- [转]UML八大误解
潘加宇 本文删节版发表于<程序员>2013年11期 UML(统一建模语言)是软件建模的表示法标准.我从2002年开始专门从事研究和推广UML的工作,在为软件组织提供UML相关需求和设计技能 ...
- 配置 Sublime Text 用 Node.js 执行 JavaScript 程序
1. 首先到 nodejs.org 下载 Node.js 安装包并安装. 2. 打开 Sublime Text 2 编辑器.选择菜单 Tools --> Build System --> ...
- JavaScript 32位整型无符号操作
在 JavaScript 中,所有整数字变量默认都是有符号整数,这意味着什么呢? 有符号整数使用 31 位表示整数的数值,用第 32 位表示整数的符号,0 表示正数,1 表示负数. 数值范围从 -2^ ...
- sp_executesql 两种写法
写法1: AlTER PROCEDURE TryAgain @ReturnValue int output AS declare @aa nvarchar(), @ForumID int, @coun ...
- python异常处理(基础)
之前在学习python的时候有整理过python异常处理的文章,不够简单也不够完整,所以决定再整理一篇,算做补充. http://www.cnblogs.com/fnng/archive/2013/0 ...
- OpenCV开发环境配置-Windows/MinGW/Clion/CMake
临时更换成了TDM-GCC,和mingw类似,这里只是声明一下. 由于opencv下载下来的.exe安装包实际上是没有mingw(gcc)匹配的/动静态库,因此这些东西需要我们自己使用mingw编译. ...
- 工作流数据库表设计-ASP.NET
公司准备开发一套工作流引擎,以前没有什么OA开发经验,也是第一次设计工作流引擎,我把我的一些思路分享一下,希望得到些帮助或者能帮助到一些人. 产品的定位: 1.能够做到前后端分离 2.可以做到项目的分 ...
- IOS开发中设置控件内容对齐方式时容易混淆的几个属性
IOS开发中四个容易混淆的属性: 1. textAligment : 文字的水平方向的对齐方式 1> 取值 NSTextAlignmentLeft = 0, // 左对齐 NST ...
- CheckListBox的实现方式分析
实际项目中常常要实现有CheckBox列表框.但是WPF没有自带这样的一个控件,下面就用Style来实现这样的功能.而对于CheckBox列表框,又常常会有一个Select All的CheckBox来 ...
- enum to IEnumerable<T>
想foreach一个枚举,发觉它特别复杂,因此先把枚举转换为IEnumerable接口之后,简单多了.下面是枚举(enum)转换为IEnumerable接口方法: 使用:修改这篇<程序一旦发觉写 ...