技术标签: echarts
在上一篇ECharts入门后,主要想用ECharts做tree图,但是看了好多都无法实现从本地读取json文件来实现的,涉及到ajax跨域问题,一直以为问题无法解决,看了别人做的demo也解决不了遇到的问题。
现在把解决后的结果贴上来
首先保证json文件是正确的,以官方例子为准flare.json
标签主要为name children 在遇到无法解析时,先查看json格式,保证json格式正确,包括有无 “,”都会造成无法解析
{
"name": "flare",
"children": [
{
"name": "{a|analytics}",
"label":{
"rich":{
"a":{
"color":"blue",
"fontSize":"16"
}
}
},
"lineStyle":{
"color":"red",
"width":"5"
},
"children": [
{
"name": "cluster",
"children": [
{"name": "AgglomerativeCluster", "value": 3938},
{"name": "CommunityStructure", "value": 3812},
{"name": "HierarchicalCluster", "value": 6714},
{"name": "MergeEdge", "value": 743}
]
},
{
"name": "graph",
"children": [
{"name": "BetweennessCentrality", "value": 3534},
{"name": "LinkDistance", "value": 5731},
{"name": "MaxFlowMinCut", "value": 7840},
{"name": "ShortestPaths", "value": 5914},
{"name": "SpanningTree", "value": 3416}
]
},
{
"name": "optimization",
"children": [
{"name": "AspectRatioBanker", "value": 7074}
]
}
]
},
{
"name": "animate",
"children": [
{"name": "Easing", "value": 17010},
{"name": "FunctionSequence", "value": 5842},
{
"name": "interpolate",
"children": [
{"name": "ArrayInterpolator", "value": 1983},
{"name": "ColorInterpolator", "value": 2047},
{"name": "DateInterpolator", "value": 1375},
{"name": "Interpolator", "value": 8746},
{"name": "MatrixInterpolator", "value": 2202},
{"name": "NumberInterpolator", "value": 1382},
{"name": "ObjectInterpolator", "value": 1629},
{"name": "PointInterpolator", "value": 1675},
{"name": "RectangleInterpolator", "value": 2042}
]
},
{"name": "ISchedulable", "value": 1041},
{"name": "Parallel", "value": 5176},
{"name": "Pause", "value": 449},
{"name": "Scheduler", "value": 5593},
{"name": "Sequence", "value": 5534},
{"name": "Transition", "value": 9201},
{"name": "Transitioner", "value": 19975},
{"name": "TransitionEvent", "value": 1116},
{"name": "Tween", "value": 6006}
]
},
{
"name": "data",
"children": [
{
"name": "converters",
"children": [
{"name": "Converters", "value": 721},
{"name": "DelimitedTextConverter", "value": 4294},
{"name": "GraphMLConverter", "value": 9800},
{"name": "IDataConverter", "value": 1314},
{"name": "JSONConverter", "value": 2220}
]
},
{"name": "DataField", "value": 1759},
{"name": "DataSchema", "value": 2165},
{"name": "DataSet", "value": 586},
{"name": "DataSource", "value": 3331},
{"name": "DataTable", "value": 772},
{"name": "DataUtil", "value": 3322}
]
},
{
"name": "display",
"children": [
{"name": "DirtySprite", "value": 8833},
{"name": "LineSprite", "value": 1732},
{"name": "RectSprite", "value": 3623},
{"name": "TextSprite", "value": 10066}
]
},
{
"name": "flex",
"children": [
{"name": "FlareVis", "value": 4116}
]
},
{
"name": "physics",
"children": [
{"name": "DragForce", "value": 1082},
{"name": "GravityForce", "value": 1336},
{"name": "IForce", "value": 319},
{"name": "NBodyForce", "value": 10498},
{"name": "Particle", "value": 2822},
{"name": "Simulation", "value": 9983},
{"name": "Spring", "value": 2213},
{"name": "SpringForce", "value": 1681}
]
},
{
"name": "query",
"children": [
{"name": "AggregateExpression", "value": 1616},
{"name": "And", "value": 1027},
{"name": "Arithmetic", "value": 3891},
{"name": "Average", "value": 891},
{"name": "BinaryExpression", "value": 2893},
{"name": "Comparison", "value": 5103},
{"name": "CompositeExpression", "value": 3677},
{"name": "Count", "value": 781},
{"name": "DateUtil", "value": 4141},
{"name": "Distinct", "value": 933},
{"name": "Expression", "value": 5130},
{"name": "ExpressionIterator", "value": 3617},
{"name": "Fn", "value": 3240},
{"name": "If", "value": 2732},
{"name": "IsA", "value": 2039},
{"name": "Literal", "value": 1214},
{"name": "Match", "value": 3748},
{"name": "Maximum", "value": 843},
{
"name": "methods",
"children": [
{"name": "add", "value": 593},
{"name": "and", "value": 330},
{"name": "average", "value": 287},
{"name": "count", "value": 277},
{"name": "distinct", "value": 292},
{"name": "div", "value": 595},
{"name": "eq", "value": 594},
{"name": "fn", "value": 460},
{"name": "gt", "value": 603},
{"name": "gte", "value": 625},
{"name": "iff", "value": 748},
{"name": "isa", "value": 461},
{"name": "lt", "value": 597},
{"name": "lte", "value": 619},
{"name": "max", "value": 283},
{"name": "min", "value": 283},
{"name": "mod", "value": 591},
{"name": "mul", "value": 603},
{"name": "neq", "value": 599},
{"name": "not", "value": 386},
{"name": "or", "value": 323},
{"name": "orderby", "value": 307},
{"name": "range", "value": 772},
{"name": "select", "value": 296},
{"name": "stddev", "value": 363},
{"name": "sub", "value": 600},
{"name": "sum", "value": 280},
{"name": "update", "value": 307},
{"name": "variance", "value": 335},
{"name": "where", "value": 299},
{"name": "xor", "value": 354},
{"name": "-", "value": 264}
]
},
{"name": "Minimum", "value": 843},
{"name": "Not", "value": 1554},
{"name": "Or", "value": 970},
{"name": "Query", "value": 13896},
{"name": "Range", "value": 1594},
{"name": "StringUtil", "value": 4130},
{"name": "Sum", "value": 791},
{"name": "Variable", "value": 1124},
{"name": "Variance", "value": 1876},
{"name": "Xor", "value": 1101}
]
},
{
"name": "scale",
"children": [
{"name": "IScaleMap", "value": 2105},
{"name": "LinearScale", "value": 1316},
{"name": "LogScale", "value": 3151},
{"name": "OrdinalScale", "value": 3770},
{"name": "QuantileScale", "value": 2435},
{"name": "QuantitativeScale", "value": 4839},
{"name": "RootScale", "value": 1756},
{"name": "Scale", "value": 4268},
{"name": "ScaleType", "value": 1821},
{"name": "TimeScale", "value": 5833}
]
},
{
"name": "util",
"children": [
{"name": "Arrays", "value": 8258},
{"name": "Colors", "value": 10001},
{"name": "Dates", "value": 8217},
{"name": "Displays", "value": 12555},
{"name": "Filter", "value": 2324},
{"name": "Geometry", "value": 10993},
{
"name": "heap",
"children": [
{"name": "FibonacciHeap", "value": 9354},
{"name": "HeapNode", "value": 1233}
]
},
{"name": "IEvaluable", "value": 335},
{"name": "IPredicate", "value": 383},
{"name": "IValueProxy", "value": 874},
{
"name": "math",
"children": [
{"name": "DenseMatrix", "value": 3165},
{"name": "IMatrix", "value": 2815},
{"name": "SparseMatrix", "value": 3366}
]
},
{"name": "Maths", "value": 17705},
{"name": "Orientation", "value": 1486},
{
"name": "palette",
"children": [
{"name": "ColorPalette", "value": 6367},
{"name": "Palette", "value": 1229},
{"name": "ShapePalette", "value": 2059},
{"name": "SizePalette", "value": 2291}
]
},
{"name": "Property", "value": 5559},
{"name": "Shapes", "value": 19118},
{"name": "Sort", "value": 6887},
{"name": "Stats", "value": 6557},
{"name": "Strings", "value": 22026}
]
},
{
"name": "vis",
"children": [
{
"name": "axis",
"children": [
{"name": "Axes", "value": 1302},
{"name": "Axis", "value": 24593},
{"name": "AxisGridLine", "value": 652},
{"name": "AxisLabel", "value": 636},
{"name": "CartesianAxes", "value": 6703}
]
},
{
"name": "controls",
"children": [
{"name": "AnchorControl", "value": 2138},
{"name": "ClickControl", "value": 3824},
{"name": "Control", "value": 1353},
{"name": "ControlList", "value": 4665},
{"name": "DragControl", "value": 2649},
{"name": "ExpandControl", "value": 2832},
{"name": "HoverControl", "value": 4896},
{"name": "IControl", "value": 763},
{"name": "PanZoomControl", "value": 5222},
{"name": "SelectionControl", "value": 7862},
{"name": "TooltipControl", "value": 8435}
]
},
{
"name": "data",
"children": [
{"name": "Data", "value": 20544},
{"name": "DataList", "value": 19788},
{"name": "DataSprite", "value": 10349},
{"name": "EdgeSprite", "value": 3301},
{"name": "NodeSprite", "value": 19382},
{
"name": "render",
"children": [
{"name": "ArrowType", "value": 698},
{"name": "EdgeRenderer", "value": 5569},
{"name": "IRenderer", "value": 353},
{"name": "ShapeRenderer", "value": 2247}
]
},
{"name": "ScaleBinding", "value": 11275},
{"name": "Tree", "value": 7147},
{"name": "TreeBuilder", "value": 9930}
]
},
{
"name": "events",
"children": [
{"name": "DataEvent", "value": 2313},
{"name": "SelectionEvent", "value": 1880},
{"name": "TooltipEvent", "value": 1701},
{"name": "VisualizationEvent", "value": 1117}
]
},
{
"name": "legend",
"children": [
{"name": "Legend", "value": 20859},
{"name": "LegendItem", "value": 4614},
{"name": "LegendRange", "value": 10530}
]
},
{
"name": "operator",
"children": [
{
"name": "distortion",
"children": [
{"name": "BifocalDistortion", "value": 4461},
{"name": "Distortion", "value": 6314},
{"name": "FisheyeDistortion", "value": 3444}
]
},
{
"name": "encoder",
"children": [
{"name": "ColorEncoder", "value": 3179},
{"name": "Encoder", "value": 4060},
{"name": "PropertyEncoder", "value": 4138},
{"name": "ShapeEncoder", "value": 1690},
{"name": "SizeEncoder", "value": 1830}
]
},
{
"name": "filter",
"children": [
{"name": "FisheyeTreeFilter", "value": 5219},
{"name": "GraphDistanceFilter", "value": 3165},
{"name": "VisibilityFilter", "value": 3509}
]
},
{"name": "IOperator", "value": 1286},
{
"name": "label",
"children": [
{"name": "Labeler", "value": 9956},
{"name": "RadialLabeler", "value": 3899},
{"name": "StackedAreaLabeler", "value": 3202}
]
},
{
"name": "layout",
"children": [
{"name": "AxisLayout", "value": 6725},
{"name": "BundledEdgeRouter", "value": 3727},
{"name": "CircleLayout", "value": 9317},
{"name": "CirclePackingLayout", "value": 12003},
{"name": "DendrogramLayout", "value": 4853},
{"name": "ForceDirectedLayout", "value": 8411},
{"name": "IcicleTreeLayout", "value": 4864},
{"name": "IndentedTreeLayout", "value": 3174},
{"name": "Layout", "value": 7881},
{"name": "NodeLinkTreeLayout", "value": 12870},
{"name": "PieLayout", "value": 2728},
{"name": "RadialTreeLayout", "value": 12348},
{"name": "RandomLayout", "value": 870},
{"name": "StackedAreaLayout", "value": 9121},
{"name": "TreeMapLayout", "value": 9191}
]
},
{"name": "Operator", "value": 2490},
{"name": "OperatorList", "value": 5248},
{"name": "OperatorSequence", "value": 4190},
{"name": "OperatorSwitch", "value": 2581},
{"name": "SortOperator", "value": 2023}
]
},
{"name": "Visualization", "value": 16540}
]
}
]
}
其次就是html
此处要注意的有两个地方
1.必须引用jquery的script,即 <script src="https://cdn.staticfile.org/jquery/1.10.2/jquery.min.js"></script>
2.$.getJSON('data.json', function (data) 官网上是$.get('data.json', function (data),但此时是直接从本地访问JSON,故必须使用前一种形式
<!DOCTYPE html>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<html>
<head>
<meta charset="UTF-8">
<!--include ECharts document-->
<script src="echarts.min.js" charset="UTF-8"></script>
<script src="https://cdn.staticfile.org/jquery/1.10.2/jquery.min.js"></script>
<title>
ECharts de Hello World
</title>
</head>
<body>
<!--prepare a DOM with size for ECharts-->
<div id="main" style="width: 600px;height: 400px;"></div>
<div id="main2" style="width: 600px;height: 400px;"></div>
<script type="text/javascript">
var myChart = echarts.init(document.getElementById('main'));
myChart.showLoading();
$.getJSON('data.json', function (data) {
myChart.hideLoading();
echarts.util.each(data.children, function (datum, index) {
index % 2 === 0 && (datum.collapsed = true);
});
myChart.setOption(option = {
tooltip: {
trigger: 'item',
triggerOn: 'mousemove'
},
series: [
{
type: 'tree',
data: [data],
top: '1%',
left: '7%',
bottom: '1%',
right: '20%',
symbolSize: 7,
label: {
normal: {
position: 'left',
verticalAlign: 'middle',
align: 'right',
fontSize: 11
}
},
leaves: {
label: {
normal: {
position: 'right',
verticalAlign: 'middle',
align: 'left'
}
}
},
expandAndCollapse: true,
animationDuration: 550,
animationDurationUpdate: 750
}
]
});
});
</script>
</body>
</html>
SFB 项目经验-72-项目02分享-Exchange 2010-升级-Exchange 2016(跨林)(2019年01月)项目需求:1)跨林迁移Exchange 2010 高可用到 Exchange 2016。2)用户数:800用户。3)数据量:1-2TB。4)时间点:2019年年前迁移完成!!!5)开始点:项目启于2019年年前1周-2周。6)联系人:从总部同步几万...
一、Quartz1、简介起初是OpenSymphony组织提供的一个功能丰富的开源作业调度框架官网:http://www.quartz-scheduler.org/纯java编写,用法简单而功能强大。2、特点强大的作业调度功能作为spring默认的调度框架,极易与spring无缝整合,实现灵活可配置的调度功能,quartz提供了调 度运行环境持久化机制,可以保存并恢复调度现场,即使系统因故障关闭也不会造成调度现场的数据丢失。灵活的应用方式允许我们灵活定义触发器的调度时间规则,并可以将_springboot通过quartz实现定时调度
yum简单来讲就是一个资源库yum是从国外的服务器上所以国内下载资源是非常耗时的,虽然阿里已将常用的一些资源封装到自己的服务器上供国人共享,但相对与本地下载还是时间较长的。本文将介绍两种yum的配置_龙晰 公网源
import requests,refrom openpyxl.workbook import Workbookfrom openpyxl.writer.excel import ExcelWriterdef get_page(url): headers = { "User-Agent":"Mozilla/5.0 (Macintosh; U; Intel Mac OS X...
本篇文章我们以抓取历史天气数据为例,简单说明数据抓取的两种方式: 1、一般简单或者较小量的数据需求,我们以requests(selenum)+beautiful的方式抓取数据 2、当我们需要的数据量较多时,建议采用scrapy框架进行数据采集,scrapy框架采用异步方式发起请求,数据抓取效率极高。 下面我们以http://www.tianqihouba..._爬取历史天气数据的原因分析
重采样主要是分为上采样和下采样,在进行采样的过程中,需要注意采样的倍率的问题,并不是可以随意的改变采样率的大小的,根据采样定理:在进行模拟/数字信号的转换过程中,当采样频率大于信号中最高频率的2倍时,采样之后的数字信号完整地保留了原始信号中的信息,一般实际应用中保证采样频率为信号是最高频率的5~10倍。采样定理又称奈奎斯特定理。采样频率:采样频率,也称为采样速度或者采样率,定义了每秒从连续信..._重采样
环境:Navicat数据库创建数据库创建数据库就是在数据库系统中划分一块存储数据的空间。注意:数据库名称是唯一的,不可以重复创建一个名为testdb的数据库CREAT DATABASE testdb查看数据库数据库创建成功后可以使用SHOW语句验证是否创建成功查看所有的数据库CREAT DATABASES查看某个已经创建的数据库SHOW CREATE DATABASE testdb修改数据库Mysql一旦安装成功,创建的数据库编码也确定。修改数据库编码格式可以使_创建数据库及在db s中划分一块儿储存数据的
以下大部分来自其他博客,谢谢! 在开发项目的时候我们免不了使用一些第三方的库来进行快速开发,有些第三方库只是简单的一个jar包,但是有些使用了jni开发,因此会包含so库文件,这个时候如果不消息我们就会遇到一个错误:java.lang.UnsatisfiedLinkError; 最近经常遇到有开发者在问使用环信sdk的时候出现这个错误;这里分享下问题原因以及解..._unsatisfiedlinkerror
好无聊好寂寞,来玩一下。。。。因为我不是程序猿,所以应该闯不到头的。。。。边闯边写就是了 第一关链接请戳 http://segmentfault.com/game/ 第一关查看源代码即可 于是得到第二关链接http://segmentfault.com/game/?k=d677c833e6d6af85176dc8ff32158
<?phpnamespace app\common\lib\built;use app\platform\model\PaymentConfig;/** * 微信支付 * Class WxPayment * @package app\common\lib\built */class WxPayment{ protected $authorization = 'WECHATPAY2-SHA256-RSA2048'; //认证类型 protected $metho
《暗黑3》为啥爆不出好装备?服务器IP决定你的人品2012-08-07 09:33:24来源:游戏下载编辑:末日使者评论(0)国外某著名D3论坛正在被国外玩家置顶讨论的话题:观点认为掉落与游戏房间所在服务器相关,即不同服务器之间的掉率不同。或许只是传言简单来讲,就是要避开掉率低的服务器,进入掉率高的服务器进行MF。操作方法是:当你建立房间后(指你选择了一个进度并进行游戏,不是在登录界面,也不是人物...
以上demo,完整案例请下载:example-MyconfirmDialog或者访问github地址:https://github.com/Kybs0/Kybs0HtmlCssJsDemo/tree/master/definedAlertWindow自定义动态确认框假如一个页面有多个业务需要确认框,上面的确认框就显得代码冗余了。下面提供一个确认框的组件:1. 定义弹出框的组件安装动画过渡组件Re..._手机端 html 确认对话框 自定义文字内容怎么设置