このページのトップへ
カスタムチャートの作成

カスタムチャートの作成

JavaScriptのポストメッセージを使ってHTMLコンポーネントと通信する。

中級.png

上級

23K

出版された:

2020年1月1日

酒を楽しむ少女

によって

アンカー 1
開発者を雇う

説明例

This example demonstrates how to use the HTML component to embed a chart on a page. This is just one of the many things you can embed in your site using the HTML component.

コード例

タブ1

.

タブ2

.

タブ3

.

このコードによる解決は複雑になる可能性がある。

どのように構築したか

Here we embed a Chart.js chart. The HTML code for the chart is entered into the HTML Component using its Edit Code button. The page and the HTML component communicate with each other using the postMessage and onMessage functions.


When the page loads and each time a year is selected using the dropdown element, the page sends a message to the HTML component using the postMessage function. The message contains the values to display in the chart. The HTML component receives the message using its onMessage function and updates the chart accordingly.


When a user clicks a bar on the chart, the HTML component sends a message to the page using its postMessage function. The message contains data about the item that was clicked. The page receives the message using the onMessage function and displays its contents to users using the text element below the chart.


The chart is based on chartjs.org. You can find their repository and license on GitHub.


次のステップ


  1. この例をエディターで開き、テンプレートを操作してください。

  2. サイトを公開する。

  3. どのように Veloでの例題の扱い方.

使用したAPI

コード以外の例。

コード以外の例。

関連記事

記事リンク

開発者を雇う

Veloソリューションは強力なツールですが、自力で構築するのは困難です。経験豊富なVelo開発会社に構築をお任せください。

関連例

これは役に立ったか?

はい

|

いいえ

ご意見ありがとう!

Chart.js Custom Element

Chart.js Custom Element

Use custom elements to implement a chart of countries and votes per country.

中級.png

上級

Stencil Branch Table

Stencil Branch Table

Embed a Web Component built using the Stencil framework

中級.png

上級

Dropdown Custom Element

Dropdown Custom Element

Create a dropdown with text and images using a custom element.

中級.png

上級

アンカー2
ページ下