使用ECharts 实现类似github的Punch Card 图

思路:

使用ECharts的Demo 里混搭图中的散饼图的思想

效果:

图1:ECharts散饼图


图2:github Punch Card图


图3:使用ECharts实现的效果图



HTML代码:

<div id="chart1" style="height:350px;"></div>

<script type="text/javascript">
    var myChart1;
    var sData1 = (function () {
        var data = [[79,66,91,65,85,77,42,56,84,52,33,52,49,19,0,0,0,6,31,22,103,83,60,87],
                    [78,90,77,61,35,53,81,35,59,61,17,9,42,0,0,0,2,9,6,13,15,16,18,50],
                    [3,26,12,23,45,51,98,102,84,56,74,30,25,15,4,0,1,0,2,2,11,5,8,6],
                 
  • 3
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
使用Java代码更新Github文件,你需要使用Github API来实现。下面是一个简单的Java代码示例,演示如何使用Github API更新文件。 ``` import org.apache.commons.codec.binary.Base64; import org.eclipse.egit.github.core.Commit; import org.eclipse.egit.github.core.Repository; import org.eclipse.egit.github.core.RepositoryContents; import org.eclipse.egit.github.core.service.ContentsService; import org.eclipse.egit.github.core.service.RepositoryService; import org.eclipse.egit.github.core.util.EncodingUtils; import java.io.IOException; import java.nio.charset.StandardCharsets; public class GithubApiExample { private static final String REPO_OWNER = "your_github_username"; private static final String REPO_NAME = "your_github_repository_name"; private static final String FILE_PATH = "path_to_your_file_in_repository"; private static final String ACCESS_TOKEN = "your_github_personal_access_token"; public static void main(String[] args) throws IOException { RepositoryService repositoryService = new RepositoryService(); repositoryService.getClient().setOAuth2Token(ACCESS_TOKEN); Repository repository = repositoryService.getRepository(REPO_OWNER, REPO_NAME); ContentsService contentsService = new ContentsService(); contentsService.getClient().setOAuth2Token(ACCESS_TOKEN); RepositoryContents file = contentsService.getContents(repository, FILE_PATH); String decodedContent = new String(Base64.decodeBase64(file.getContent()), StandardCharsets.UTF_8); String newContent = "Hello, Github API!"; Commit commit = new Commit(); commit.setMessage("Update file via Github API"); String encodedContent = EncodingUtils.toBase64(newContent.getBytes()); contentsService.updateFile(repository, FILE_PATH, commit, encodedContent, file.getSha()); } } ``` 在这个示例中,我们使用Github API的Java库,Eclipse EGit。这个库提供了对Github API的访问。 首先,我们需要获取访问Github API所需的访问令牌。然后,我们使用RepositoryService和ContentsService连接到Github API。 接下来,我们获取要更新的文件的内容。我们使用Base64编码将内容解码为字符串。 然后,我们创建一个新的字符串,并将其编码为Base64格式。最后,我们使用ContentsService的updateFile方法更新文件。我们提供了文件的路径、提交信息、新的内容和文件的SHA哈希值。 这是一个简单的Java代码示例,演示如何使用Github API更新文件。请注意,这个示例假定你已经安装了Eclipse EGit库,并且已经获取了Github API的访问令牌。
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值